user(); if (!$user) { abort(403, 'Unauthorized action.'); } // Use can() instead of hasPermissionTo() to work with Gate definitions // can() is more flexible and works with the multi-guard permission system. // Multiple middleware params are treated as "any of" (e.g. `user.can:access profiles,access accounts`). foreach ($permissions as $permission) { if ($user->can($permission)) { return $next($request); } } abort(403, 'Unauthorized action.'); } }