for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Mongi\Mongicommerce\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class AdminMiddleware
{
public function handle($request, Closure $next)
if (!Auth::check()) {
// I included this check because you have it, but it really should be part of your 'auth' middleware, most likely added as part of a route group.
return redirect(route('admin.login'));
}
// Perform action
$user = Auth::user();
if ($user->admin == true) {
admin
Illuminate\Contracts\Auth\Authenticatable
instanceof
return $next($request);
} else {
abort(403);