after login redirect to another page laravel 7 other than home code example

Example 1: how to redirect to another page after login in laravel

protected function authenticated(Request $request, $user) {
	 if ($user->role_id == 1) {
	 	return redirect('/admin');
	 } else if ($user->role_id == 2) {
	 	return redirect('/author');
	 } else {
	 	return redirect('/blog');
	 }
}

Example 2: redirect after login laravel

class RegisterController extends Controller
{
    protected $redirectTo = '/home';

    protected function redirectTo()
    {
        if (auth()->user()->role_id == 1) {
            return '/admin';
        }
        return '/home';
    }

}

Tags:

Php Example