Closed Sysix closed 7 years ago
I think you should be able to do it with relation/get method in your model.
public function hasPerm($perm)
{
$perms = $this->relation('perms'); //returns HasManyRelation object
if ($perms === false) {
//Relation is not loaded
}
//logic to check if user has perm
foreach ($perms as $userPerm) {
//...
}
return false; //or whatever
}
Thanks ;) I thought that could be done easier without an foreach loop.
Hello Guys,
I'm back with a new question ;)
My Setup:
User
,UserPerm
andUserPermRelation
)User
-Model as initial no Relation set ($mapper->first(['id' => 1]);
)UserPermRelation (I hope that the Relation is enough Information for my Problem)
Now I want to add on my
User
-Model a Method called$user->hasPerm($perm)
How do I solve this? I found example like #186 but it not works like I thought.Thanks for your help!