I am Kingsley Okpara, a Python and PHP Fullstack Web developer and tech writer, I also have extensive knowledge and experience with JavaScript while working on applications developed with VueJs.
if I understand your question, that is, you have different classes of users, you want to direct them to their dashboard on login.
You can write a helper function, use if statement to determine what the function returns
Go to RouteServiceProvider.php in app\Providers\RouteServiceProvider
public const HOME = '/dashboard';, change the '/dashboard/' to the helper function
grab the user's id using Auth
use Illuminate\Support\Facades\Auth;
$id = Auth::id();
how do you determine the class of the user (different user)
I am Kingsley Okpara, a Python and PHP Fullstack Web developer and tech writer, I also have extensive knowledge and experience with JavaScript while working on applications developed with VueJs.
if I understand your question, that is, you have different classes of users, you want to direct them to their dashboard on login.
. I have used this way but it's not working. Is there any way to redirect user by using middleware
public function redirectTo()
{
$role = Auth::user()->role_id;
switch ($role) {
case '1':
return redirect(route('dashboard'));
break;
case '2':
return redirect(route('judge_dashboard'));
case '3':
return redirect(route('user_dashboard'));
default:
return '/login';
break;
}
}
Hello, sorry I missed your comment, have you resolved it? you can still reach out to me, if you have not