Pass through additional arguments to Gate check
This commit is contained in:
parent
6e2049afd5
commit
a72bcffe1a
|
|
@ -66,9 +66,13 @@ function authenticated(): Closure
|
|||
};
|
||||
}
|
||||
|
||||
function can(string $ability): Closure
|
||||
function can(string $ability, ...$args): Closure
|
||||
{
|
||||
return function ($arg) use ($ability) {
|
||||
return Gate::allows($ability, $arg instanceof Model ? $arg : null);
|
||||
return function ($arg) use ($ability, $args) {
|
||||
if ($arg instanceof Model) {
|
||||
array_unshift($args, $arg);
|
||||
}
|
||||
|
||||
return Gate::allows($ability, $args);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue