user(); // Use can() instead of hasPermissionTo() to work with Gate definitions // can() is more flexible and works with the multi-guard permission system if (!$user || !$user->can($permission)) { abort(403, 'Unauthorized action.'); } return $next($request); } }