Mahmoud Abd AL Kareem
Mahmoud Abd AL Kareem

Reputation: 645

Laravel 5.2 validation on joined table

I want to make validation on a joined table,I know that laravel 5.2 doesn't support this. what is the best practice to do that ? any suggestions?

Upvotes: 0

Views: 53

Answers (1)

saimcan
saimcan

Reputation: 1762

The best way to do this, manually authenticate the user with the values you've grabbed from your joined database.

The fastest solution I've brought up is like this:

//join the tables and name it as $joined_table_values
if(isset($joined_table_values)){
   if($joined_table_values->field == 'theValueYouNeed'){
      //Then authenticate manually with the values in default users table
      if (Auth::attempt(['email' => $email, 'password' => $password])) {
         // Authentication passed...
         return redirect()->intended('dashboard');
      }
   }
}

Resource: https://laravel.com/docs/5.2/authentication#authenticating-users

Upvotes: 1

Related Questions