so this is basically the sql model i got so far:

This is, how it would look at my users controller (stackoverflow formatting):
if (Auth::user()->is('admin'))
{
if (Auth::user()->can('delete'))
{
echo 'hurra!';
}
}
Permission keys will probably look like this
admin.delete
maybe something like user.can.buy
And now i want to know if it’s alright, how i perform it in the methods:
public function is($roleName)
{
$role = $this->roles;
if ($role->name == $roleName)
{
return true;
}
return false;
}
I think this one’s good
BUT
public function can($permissionKey)
{
$permissions = $this->roles->permissions()
->where('key', $permissionKey)
->count();
if ($permissions > 0)
{
return true;
}
return false;
}
looks kinda awkward to me. Is this the right way i am selecting data with eloquent orm?
Thanks in advance!
Well i lnstalled a profiler and checked all triggered sql queries:
select * from
userswhereid= ‘1’ limit 1select * from
roleswhereid= ‘1’ limit 1select count(*) as aggregate from
permissionsinner joinpermission_roleonpermissions.id=permission_role.permission_idwherepermission_role.role_id= ‘1’ andkey= ‘view.admin’this looks alright to me, so i think the way i did it, is ok.