Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dtommy79's avatar

Laravel 8 Fortify redirect after login based on roles

Hi, I've implemented roles on my website with role_id = 1 for admin and role_id = 2 for members. How can I redirect them to separate views after login? Currently it redirects everyone to the "home" uri.

I guess I need to change this

'home' => RouteServiceProvider::HOME,

in config/fortify.php

0 likes
6 replies
dtommy79's avatar

@MichalOravec Thanks. I've found the second one too.

But how can I change this conditionally:

$home = auth()->user()->is_admin ? '/admin' : '/dashboard';

in my users table I have a role_id column with 1 for admin and 2 for members.

MichalOravec's avatar
Level 75

@dtommy79 What is a problem with it for you?

$home = auth()->user()->role_id == 1 ? '/admin' : '/member';

Please or to participate in this conversation.