I want to implement must verify in admin routes, i have admin guard and all routes related to admin, how can i achieve this functionality for admin guard in Laravel 5.7
Email Verification in laravel 5.7 for admin guard
1.8k Views Asked by Krish Bhardwaj At
2
There are 2 best solutions below
2

In laravel6, laravel7, we can do it by passing route name in middleware parameter. For example:
Route::middleware('verified:admin.verification.notice')->get('/', 'AdminController@home')->name('home');
Here "dashboard.verification.notice" is the name of verify email route for my admin guard.
===================================================================
Explanation:
Take a look on "handle" method of "EnsureEmailIsVerified" middleware.
public function handle($request, Closure $next, $redirectToRoute = null)
{
if (! $request->user() ||
($request->user() instanceof MustVerifyEmail &&
! $request->user()->hasVerifiedEmail())) {
return $request->expectsJson()
? abort(403, 'Your email address is not verified.')
: Redirect::route($redirectToRoute ?: 'verification.notice');
}
return $next($request);
}
It's 3rd parameter take the $redirectToRoute name
This is how I got it to work for me.
Kindly note that
instance of MustVerifyEmail
did not work that is why I went with Admin model.Register it in your kernel as always,
in the $routesMiddlewareGroup
I hope this helps
Admin Dashboard - Email Verification