I am trying to modify Laravel, so it will check whether or not the logged in user have logged in before or not, no matter what page they will navigate to on their first login.
At the moment, I can only get it to work if the user is redirected to "/home"
on the first login:
UserController.php
:
public function index()
{
$user = Auth::user();
if (!$user->last_login){
//This will redirect the user to the onboarding area, if they haven't logged in before.
return redirect()->route('onboarding');
}else{
if ($user->isAdmin()) {
return view('pages.admin.home');
}
return view('pages.user.home');
}
}
public function onboarding(){
//If the user hasn't logged in yet, let's onboard him/her
//Please check function index(), for the actual redirect.
return view('onboarding.home');
}
routes/Web.php
:
//Onboarding
Route::get('/onboarding', 'UserController@Onboarding')->name('onboarding');
Now as said, it will only redirect if the user navigates to "/home"
, however if the user decides to go to for example "/profile"
, he/she will not be redirected to "/onboarding"
.
Where is the most appropriate place to make this check?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire