Well if I set up some kind of helper method (or custom collection) won't it iterate through the list of permissions each time to find a match?
I think it would be more efficient to just have something like:
return $user->permissions->post_item === 'admin';
Which of course can be wrapped in some kind of helper method or function. I have a lot of permissions, about 30 with a range of levels for each permission. With all the users and checks it seems like a lot of iterating.
I think running through the list once before caching the user object is the best way.
However this poses issues as I have to store it in another variable/object since I can't overwrite the original
permissions data set. Which means I have two sets of the data now.
Ultimately I would just like one data set:
$user->permissions = (object) [
'post_item' => 'super',
'put_item' => 'admin'
Then just access them directly to see if the proper permission level is set.