cybercog/laravel-ownership

OwnedOrFail

blendsoft opened this issue · 3 comments

Could you add method(s) throwing exception when not owner ?

@blendsoft Throw exception when model don't have any owners or when exact user not an owner of it?

Could you provide usage example, please?

You can use default firstOrFail method mixed with whereOwnedBy scope:

Article::whereKey($articleId)->whereOwnedBy($user)->firstOrFail();

Does this help?

Closing this issue. Feel free to continue conversation if solution proposed above didn't help.