I am trying to make laravel basic authorization. I'm using gate for laravel authorization.
This is my table structure :
User Table, Permission Table, Role, role_permission table
user : id, name , password, email
permission : id, name
role:id , name
role_permission: id, role_id, permission_id
Here is code inside of AuthServiceProvider
public function boot(GateContract $gate)
{
$this->registerPolicies();
foreach($this->getPermissions() as $permission)
{
dd($permission);
$gate->define($permission->name,function($user) use($permission){
// dd($permission->role->id);
return $user->role->id == $permission->role->id;
});
}
}
public function getPermissions()
{
return Permission::with('role')->get();
}
But the problem is it doesn't work properly means I can't access the route though it's there in permission table with the appropriate user.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2kRHD2d
via IFTTT
Aucun commentaire:
Enregistrer un commentaire