shrutiupari

shrutiupari

Member Since 9 Months Ago

Experience Points 350
Experience Level 1

4,650 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

13 Jun
4 days ago

shrutiupari left a reply on Laravel Login Using Id From Different Database

<?php

namespace App\Http\Controllers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Requests\CreateUserRequest;
use UxWeb\SweetAlert;
use App\LegonUser;
use Request;
use Alert;
use DB;

class LegonUserController extends Controller
{
    //
    public function index()
    {
        # code...
        return view('login');
    }

    public function LegonSignin() {
    $input = Request::all();
          $user_data = [
          'tgi' => $input['tgi'],
          'pass' => $input['pass']
        ];

    //$database = LegonUser::on('mysql2')->select('*')->where($user_data ,'=',         $user_data)->get();
    $legonModel = new LegonUser;
    $legonDB = \DB::connection('mysql_external');
    $logindata = $legonDB->table('emp_username_db')->select('tgi', 'pass', 'emp_id')->where('tgi', '=', $input['tgi'])->get();

        if ($logindata) {
            print_r($logindata);
            // return redirect('/');
           }else {
            return redirect()->back()->withErrors($user_data);
          }
        
   
}

    public function getTest()
    {
        $db_ext = \DB::connection('mysql_external');
        $countries = $db_ext->table('emp_username_db')->select('tgi', 'pass')->get();
        print_r($countries);
    }

} 

HomeController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('/home');
    }
}

I have done changes in config/database.php and config/auth.php as suggested in this https://laracasts.com/discuss/channels/eloquent/laravel-5-multiple-database-connection link. The login.blade.php remains the same but with different values passed as shown in the LegonUserController.php.

shrutiupari left a reply on Laravel Login Using Id From Different Database

I will show the Entire code you can check it. User.php

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    protected $connection = 'mysql_external';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $primaryKey = 'id';
    protected $fillable = [
        'id', 'emp_id', 'tgi', 'pass',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'pass',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */    
}
    ```

LegonUser.php

shrutiupari left a reply on Laravel Login Using Id From Different Database

<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Requests\CreateUserRequest;
use UxWeb\SweetAlert;
use App\LegonUser;
use Request;
use Alert;
use DB;

class LegonUserController extends Controller
{
    //
    public function index()
    {
        # code...
        return view('login');
    }

  public function LegonSignin() {
    $input = Request::all();
          

    //$database = LegonUser::on('mysql2')->select('*')->where($user_data ,'=',         $user_data)->get();
    $legonModel = new LegonUser;
    $legonDB = \DB::connection('mysql_external');
    $logindata = $legonDB->table('emp_username_db')->get();

    $user_data = array(
          'tgi' => $input['tgi'],
          'pass' => $input['pass']
        );

    if (Auth::attempt($user_data)) {
        print_r($user_data);
        // return redirect('/');
       }else {
        return redirect()->back()->withErrors($user_data);
      }
        
   
}

shrutiupari left a reply on Laravel Login Using Id From Different Database

Hi All, So far this what is did using this link https://laracasts.com/discuss/channels/eloquent/laravel-5-multiple-database-connection, I am able to get the data but its not validating. The Controller file:

12 Jun
5 days ago

shrutiupari left a reply on Laravel Login Using Id From Different Database

I changed but still no luck

shrutiupari left a reply on Laravel 5 Multiple Database Connection.

I tried in a similar way but still no luck. Please help

07 Jun
1 week ago

shrutiupari left a reply on Laravel Login Using Id From Different Database

Its showing error saying please fill in the details.

shrutiupari left a reply on Laravel Login Using Id From Different Database

I did in a similar fashion as its done for normal login. Only difference is that I created separate controller and wrote the above functions. I tried to fetch data from 2 databases only if they match and show in datatables, which is working completely fine.

shrutiupari left a reply on Laravel Login Using Id From Different Database

namespace App\Http\Controllers;

use Illuminate\Http\Request; use DB; use Auth; use App\Model\User; use App\Models\EmployeeMaster;

class AppController extends Controller { // public function __construct() {

}

public function showLoginForm(){

    return view('employeelogin');
}

public function masterlogin(Request $request) {
    
    $this->validate($request,[
        'tgi' => 'required|tgi|exists:tools_bta.emp_username_db',
        'pass' => 'required|pass|exists:tools_bta.emp_username_db',
    ]);

    if(EmployeeMaster::attempt(['tgi' => $request->tgi, 'pass' => $request->pass])){
        return "Logged in successfully";
    }else{
        return "Something went wrong";
    }
}

}

shrutiupari left a reply on Laravel Login Using Id From Different Database

Below is my separate Controller containing the functions

shrutiupari left a reply on Laravel Login Using Id From Different Database

@MUNAZZIL - I have done everything. Still I dont know why is it not logging

06 Jun
1 week ago

shrutiupari left a reply on Laravel Login Using Id From Different Database

@MUNAZZIL - <?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\AuthenticatesUsers; use DB;

class LoginController extends Controller { /* |-------------------------------------------------------------------------- | Login Controller |-------------------------------------------------------------------------- | | This controller handles authenticating users for the application and | redirecting them to your home screen. The controller uses a trait | to conveniently provide its functionality to your applications. | */

use AuthenticatesUsers;

/**
 * Where to redirect users after login.
 *
 * @var string
 */
protected $redirectTo = '/home';

/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->middleware('guest')->except('logout');
}

}

shrutiupari left a reply on Laravel Login Using Id From Different Database

@SERGIU17 - It should be other database table. Thanks I will check the video and let you know.

shrutiupari left a reply on Laravel Login Using Id From Different Database

{{ __('Login') }}
            <div class="card-body">
                <form method="POST" action="{{ route('employeelogin') }}">
                    @csrf

                    <div class="form-group row">
                        <label for="tgi" class="col-sm-4 col-form-label text-md-right">{{ __('Emp TGI') }}</label>
                        <div class="col-md-6">
                            <input id="TGI" type="text" class="form-control{{ $errors->has('TGI') ? ' is-invalid' : '' }}" name="TGI" value="{{ old('TGI') }}" required autofocus>

                            @if ($errors->has('TGI'))
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $errors->first('TGI') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="Password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>

                        <div class="col-md-6">
                            <input id="Password" type="Password" class="form-control{{ $errors->has('Password') ? ' is-invalid' : '' }}" name="Password" required>

                            @if ($errors->has('Password'))
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $errors->first('Password') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group row mb-0">
                        <div class="col-md-8 offset-md-4">
                            <button type="submit" class="btn btn-primary">
                                {{ __('Login') }}
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

The view file

shrutiupari left a reply on Laravel Login Using Id From Different Database

Yes I have done it. But not getting how to and where to do the changes. I have created separate login page and then I am confused as to where should I write the query such that I must be able to login only if user exists in the other database.

shrutiupari started a new conversation Laravel Login Using Id From Different Database

I have so far changed the config/database.php file and even the .env file and set it to my 2 of the databases. But I am not able to login using the id. Can anybody please help me.

12 Sep
9 months ago

shrutiupari left a reply on How To Insert Into Table Only If The Status Is "approved" In Other Table?

@Snapey I want to insert only if the student has filled the form and whose status is "Applied/Mail Send". If there is no such application form filled by him then student should not be created.

shrutiupari left a reply on How To Insert Into Table Only If The Status Is "approved" In Other Table?

@jlrdw I am able to add student even after checking status. I need to check whether status is "Applied" or "Mail Send" for that particular student.

11 Sep
9 months ago

shrutiupari left a reply on How To Insert Into Table Only If The Status Is "approved" In Other Table?

I did check in such way as you can see in the above query using where query

shrutiupari left a reply on How To Insert Into Table Only If The Status Is "approved" In Other Table?

I have a table "Applications" where 'status' are applied, pending. So I want to create students only if (s)he has applied the application form and its status is "applied".

$appStatus = Applications::where('status', 'Applied')->orWhere('status', 'Mail Send')->first(); if($appStatus){ $status = Student::create($input + ['student_id'=>$id,'school_id'=> $this->getSelectedSchoolId()]); if($status->student_id){ if ($request->hasFile('file')) { $file = $request->file('file'); $file->move('images/student', $status->student_id.'.'.$file->getClientOriginalExtension()); $status->fill(['image'=>'/images/student/' . $status->student_id.'.'.$file->getClientOriginalExtension()]); $status->save(); } return $status; } }

shrutiupari started a new conversation How To Insert Into Table Only If The Status Is "approved" In Other Table?

Simple Insertion of data only if the status from other table is "Approved".

30 Aug
9 months ago

shrutiupari left a reply on Insert Multiple Rows Data Into Database

i tried it but still its shows null @Sergiu17

shrutiupari started a new conversation Insert Multiple Rows Data Into Database

I want to insert multiple rows data in the array format on select of drop down values. I tried all solutions but still data stored in db is null.