Laravel login using id from different database

Hi All,
I am trying to login using different database where I have already setup the config/database.php as well as .env files. Now how shall I write functions or login using LoginController? PLease anybody can help me.

Can anyone help me with this as I have seen many forums but not getting how to start. Any help would be great.

You mean, you want to run queries against two different database in the same processes?

public function LegonSignin(Request $input) {

    $rules = $this->validate($input, [
        'tgi' => 'required',
        'password' => 'required|min:4'

	  $user_data = [
	  'tgi' => $input['tgi'],
	  'password' => $input['password']

//$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', 'password', 'emp_id')->where(['tgi' => $input['tgi']])->get();

    if ($logindata) {
        return view('/home');
       }else {
        return "Failed";

So far I have written query connecting with db2. How shall I write query such that it must login only if the user exists in both databases.

where’s the query to the second database?

$existsBoth ? login() : throw new Exception('user not in both datbases') ;

That’s what I am not getting as I am finding difficulty in writing this query. How to run if condition in the query to check for users in both the databases.

so what does the DB::connection method do? It looks like you can specify a configured connection alias - that way you would just to have to use it twice with different connection aliases.

Yes I did that. Thank you for your support. Can you please suggest me some links for using Calendar in Laravel to generate reports using Angularjs

No. And i don’t see the relation to this thread.

Sponsor our Newsletter | Privacy Policy | Terms of Service