mardi 12 septembre 2017

Do i can pass dynamic values to gates through @can?

I want to pass dynamic values to a gate to prevent a block in blade,for ex. if i want to print even numbers through blade page.

@for($i=0;$i<=10;$i++)
 @can('print-even',$i) // i know its not possible i want to is there any other way
   <div > div to 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 , i want to know is there any way to do pass dynamic values to gate?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire