how do i do a switch statement with
` ``
public function toResponse($request){return $request->wantsJson()
? response()->json(['two_factor' => false])
: redirect()->intended(
auth()->user()->is_admin ? route('admin.dashboard') : route('dashboard')
auth()->user()->is_admin ? route('admin.dashboard') :route('dashboard'),
auth()->user()->is_Hr ? route('hr.dashboard') : route('dashboard'),
auth()->user()->is_clack ? route('clack.dashboard') : route('dashboard'),
auth()->user()->is_worker ? route('workes.dashboard') : route('dashboard'),
);
}`
``
want to redirect to each roles dashoard after login
redirect after login based on roles
You need to create a new method or use a variable to get the intended route, you can't use how you added it.
Following should help you, Make sure user is loggedin at this point
This code first checks each condition and returns the corresponding route if a match is found, and if none of the conditions match, it falls back to the default case and returns the route for the dashboard.