for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Cortex\Fort\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Rinvex\Fort\Models\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Database\Eloquent\Model;
class Abilities
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
// Bypass authorization check if superadmin
Gate::before(function (User $user) {
return $user->isSuperadmin() ?: null;
});
// Define abilities and policies
app('rinvex.fort.ability')->all()->map(function ($ability) {
Gate::define($ability->slug, $ability->policy ?: function (User $user, Model $resource = null) use ($ability) {
$resource
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.
return $user->allAbilities->pluck('slug')->contains($ability->slug);
return $next($request);
}
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.