php - Custom authorization parameter for a policy -
usually, policy, have parameters user , corresponding model. not seem work have custom parameters attached, though.
what like:
// mymodelpolicy.php class mymodelpolicy { public function foo(user $user, mymodel $model, $somestring) { /* ... */ } } and in blade:
// some.blade.php @can('foo', $mymodelinstance, 'tralala') however, error foo expects 3 parameters , getting two. laravel gate delivers 2 , ignores 'tralala'.
what easiest way accomplish desire?
well, turns out easier thought of... documentation fails give short example on have is, use @can in distinct way:
// some.blade.php @can('foo', [$mymodelinstance, 'tralala']) well, if api reference, see can wants array , rest follows.
wiki
Comments
Post a Comment