Skip to content

Commit a72bcff

Browse files
committed
Pass through additional arguments to Gate check
1 parent 6e2049a commit a72bcff

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/functions_laravel.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ function authenticated(): Closure
6666
};
6767
}
6868

69-
function can(string $ability): Closure
69+
function can(string $ability, ...$args): Closure
7070
{
71-
return function ($arg) use ($ability) {
72-
return Gate::allows($ability, $arg instanceof Model ? $arg : null);
71+
return function ($arg) use ($ability, $args) {
72+
if ($arg instanceof Model) {
73+
array_unshift($args, $arg);
74+
}
75+
76+
return Gate::allows($ability, $args);
7377
};
7478
}

0 commit comments

Comments
 (0)