laravel 8 redirect after login role code example

Example 1: how to redirect a particular user role to a page after login laravel

protected $redirectTo = RouteServiceProvider::HOME;

Example 2: how to redirect a particular user role to a page after login laravel

public function redirectTo() {  $role = Auth::user()->role;   switch ($role) {    case 'admin':      return '/admin_dashboard';      break;    case 'seller':      return '/seller_dashboard';      break;     default:      return '/home';     break;  }}

Tags:

Php Example