JosephSilber / bouncer

Laravel Eloquent roles and abilities.
MIT License
3.43k stars 330 forks source link

Frontend - Check if user can own a model #624

Closed webstudiosNO closed 1 year ago

webstudiosNO commented 1 year ago

I've been looking for most of the day after this question. Meybe looking in the wrong place so here it goes.

Is there a way to check in blade if a user has the ability to own a model.. eks. @canOwn(App\Models\Sale::class)

JosephSilber commented 1 year ago

What would canOwn mean?

You simply want to check whether they can do something, such as @can('view', $model). If they own that model (and have ownership permissions), that can check will return true.

So all you really need is Laravel's built-in @can Blade directive.