I have made a working middleware that forces the user to complete onboarding before progressing any further in the web site. See code below –
public function handle(Request $request, Closure $next)
{
$user = $request->user();
// if the user has completed onboarding - let them go where they need to go!
if ($user->isOnboarded())
return $next($request);
$redirectDictionary = [
0 => 'employment.index',
1 => 'qualificationsAndCertifications.index',
2 => 'extraDocs.index',
3 => 'additionalInformation.index',
];
$intendedRoute = Arr::get($redirectDictionary, $user->onboarded);
// If the user is where they are meant to be - let them proceed!
if ($intendedRoute == $request->route()->getName())
return $next($request);
return redirect()->route($intendedRoute);
}
I want to add a new route called resume onboarding. Which will appear if the user logs back in and hasn’t completed the onboarding process. I have implemented this by checking that the user’s onboarded value is <4 on login. However, this implementation is being overwritten by this middleware as it redirects the user off of that page automatically. And therefore I was wondering if there was a way of adding an exception to this middleware to allow the user to access this resume onboarding page ?