Laravel-permission: How to implement row-level permissions?

Created on 14 Feb 2018  路  6Comments  路  Source: spatie/laravel-permission

Thank you very much for this very interesting package. However, after reading the documentation I keep wondering how to implement _row-level_ permissions - something that would be very needed realistically for most systems - it would translate to e.g. "user can edit own articles and articles of only her group, but not of other users or other groups". How to do that with this package? What am I missing?

Thank you very much for your attention!

Most helpful comment

All 6 comments

The package only allows you to add & check for permissions/roles. It wont stop anyone from updating models. It sounds like you're looking for Laravel's model policies (which can be combined with this package). Have a look at https://laravel.com/docs/5.5/authorization#creating-policies.

If you've got any more questions, let me know :)

Really this example is the missing piece that connects Laravel Authorisation and Spatie/Permission.

As most laravel developers probably already using @can('view', $post) from Laravel Model Policy, the usefulness of this package becomes a little confusing.

I understanding is, in general spatie/permission cannot support so-called _row-level permission_, because there are arbitrary conditions that you'd like to check before you may grant the permission.

spatie/permission grants permission explicitly, and serves as an additional layer on top of (with or without) Laravel Model Policy.

@COLABORATI

Did you find any solution for this?

@AlexVanderbist It would be good to add one of the examples @drbyte provided, in the README page to clear the policy question about this package.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ionesculiviucristian picture ionesculiviucristian  路  4Comments

MichalKrakow picture MichalKrakow  路  4Comments

vpratfr picture vpratfr  路  4Comments

Dreambox13 picture Dreambox13  路  3Comments

bbdangar picture bbdangar  路  4Comments