laravel - Do I can pass dynamic values to gates through @can? -
i want pass dynamic values gate prevent block in blade,for ex. if want print numbers through blade page.
@for($i=0;$i<=10;$i++) @can('print-even',$i) // know not possible want there other way <div > div display </div> @endcan @endfor
in authserivceprovider.php
public function boot(gatecontract $gate) { $this->registerpolicies($gate); $gate->define('print-even', function($number){ return $number % 2 == 0; }); }
like wise , want know there way pass dynamic values gate?
you can pass additional adding gate this
$gate->define('print-even', function($user,$number){ return $number % 2 == 0; });
by default first parameter current auth::user().
Comments
Post a Comment