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
This is how I got it to work for me.
class AdminEmailIsVerified extends EnsureEmailIsVerified { public function handle($request, Closure $next) { if (! $request->user('admin') || ($request->user('admin') instanceof Admin &&//MustVerifyEmail && ! $request->user('admin')->hasVerifiedEmail())) { return $request->expectsJson() ? abort(403, 'Your email address is not verified.') : Redirect::route('admin.verification.notice'); } return $next($request); } }
Kindly note that instance of MustVerifyEmail
did not work that is why I went with Admin model.
Register it in your kernel as always,
'admin.verified' => \App\Http\Middleware\AdminEmailIsVerified::class,
in the $routesMiddlewareGroup
I hope this helps