on-internet
← Community

Laravel user capabilities

Stack Overflow ·

Within Laravel you can easily define abilities and then hook into them later on a user request regarding to do different actions: $gate->define('update-post', function ($user, $post) { return $user->id === $post->user_id; }); But almost all my defined abilities has this part $user->id === $model->user_id in it. I don't like it as it's a kind of repeating a condition over and over which I think could be more abstract. Most of my defined abilities are according to updating/deleting records, so it would be better if I could make a global condition applied to all of them or if there could be a gro

Comments

Sign in or sign up to comment and upvote.

No comments yet.