return redirect based on user role laravel 8 code example
Example 1: 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; }}
Example 2: how to redirect a particular user role to a page after login laravel
use Illuminate\Support\Facades\Auth;