I'm starting to user Gate in Laravel 5.1, and I got this code from some where in the internet.
<?php
public function boot(GateContract $gate)
{
$this->registerPolicies($gate);
/**
* NOTE!!
* First time migration will fails, because permissions table doesn't exists.
*/
foreach($this->getPermissions() as $permission) {
$gate->define($permission->path, function($user) use ($permission) {
return $user->hasRole($permission->roles);
});
}
}
My question is, what is function($user) use ($permission) {
in $gate->define($permission->path, function($user) use ($permission) {
??? Why is there use
after function()
?
If there're some references, I'd love to know/ read it.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire