I'm trying to automatically login after the user registers.
My user registeration method:
public function register_user(Request $request)
{
if (!$request->ajax()) return false;
$form_rule = [
'email' => 'required|email|max:255|unique:tdshop_user_entity',
'password' => 'required|min:6',
];
$validator = Validator::make($request->all(), $form_rule);
$status = $validator->fails();
$form_errors = [];
foreach($form_rule as $field=>$rules){
$form_errors[$field] = $validator->errors()->first($field);
}
if(!$validator->fails()){
$user = User_entity::create([
'email' => $request['email'],
'password' => bcrypt($request['password']),
]);
Auth::loginUsingId($user->user_id);
}
return json_encode([
'status' => ($status)? 'fail' : 'success',
'result' => json_encode($form_errors)
]);
}
User registration is successful. And is recorded in the database. But to login following error is displayed:
ErrorException in SessionGuard.php line 407: Argument 1 passed to Illuminate\Auth\SessionGuard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\User_entity given, called in /home/ali/www/brandmashhoor/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php on line 392 and defined
Can anyone tell me what is the correct problem.
via Ali Hesari