{"action":"created","issue":{"url":"https://api.github.com/repos/spatie/laravel-permission/issues/512","repository_url":"https://api.github.com/repos/spatie/laravel-permission","labels_url":"https://api.github.com/repos/spatie/laravel-permission/issues/512/labels{/name}","comments_url":"https://api.github.com/repos/spatie/laravel-permission/issues/512/comments","events_url":"https://api.github.com/repos/spatie/laravel-permission/issues/512/events","html_url":"https://github.com/spatie/laravel-permission/issues/512","id":266039551,"number":512,"title":"[Proposal] Role Hierarchy Level","user":{"login":"johannesschobel","id":9431350,"avatar_url":"https://avatars1.githubusercontent.com/u/9431350?v=4","gravatar_id":"","url":"https://api.github.com/users/johannesschobel","html_url":"https://github.com/johannesschobel","followers_url":"https://api.github.com/users/johannesschobel/followers","following_url":"https://api.github.com/users/johannesschobel/following{/other_user}","gists_url":"https://api.github.com/users/johannesschobel/gists{/gist_id}","starred_url":"https://api.github.com/users/johannesschobel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johannesschobel/subscriptions","organizations_url":"https://api.github.com/users/johannesschobel/orgs","repos_url":"https://api.github.com/users/johannesschobel/repos","events_url":"https://api.github.com/users/johannesschobel/events{/privacy}","received_events_url":"https://api.github.com/users/johannesschobel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-10-17T08:43:27Z","updated_at":"2017-10-17T14:14:05Z","closed_at":null,"author_association":"NONE","body":"Hey all,\r\n\r\nthanks for this awesome package - i really like it as it is quite easy to use.\r\nRecently, i stumbled upon a problem, which i thought i could share with you - this might be a contribution for your package.\r\n\r\n### Problem\r\n\r\nIn my application i have `Teams` (a `User` can be in multiple `Teams`) and `Projects` (a `Project` can have multiple `Teams`). Furthermore, a `Team` can have a specific `Role` within a `Project`. Therefore, one `User` can have multiple `Roles` within a `Project`.\r\n\r\nFor now, let us call these Roles `Owner`, `Manager` and `Member` (as they already imply some kind of `Hierarchy`: `Owner > Manager > Member`.\r\n\r\nI would like to _retrieve the `highest` (i.e., the role with the most access rights) `Role` for one specific `User` within a `Project`_.\r\n\r\n### Idea\r\n\r\nI thought it may be possible to enhance the `Role` table and add an additional `level (int, default 0)` field to the database. This field would act as some kind of `hierarchy`.\r\n\r\nIn the given example, one could just define `Owner (10) > Manager (5) > Member (1)`. Note that the numbers indicate the `level`.\r\n\r\nWhen retrieving all `Roles` for the `User` within a `Project` we would just need to `sort by level` and we're already set up!\r\n\r\nFurthermore, this idea could be enhanced in order to provide some additional functions to restrict access not only by `Role` or `Permission` but also by `Level`. Think about a method like this `hasAtLeastRoleLevel(int level)` to check, if the `level` of the `User` is higher than - therefore he has access..\r\n\r\nWhat do you think about this feature?\r\nBest\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/spatie/laravel-permission/issues/comments/337245219","html_url":"https://github.com/spatie/laravel-permission/issues/512#issuecomment-337245219","issue_url":"https://api.github.com/repos/spatie/laravel-permission/issues/512","id":337245219,"user":{"login":"drbyte","id":404472,"avatar_url":"https://avatars0.githubusercontent.com/u/404472?v=4","gravatar_id":"","url":"https://api.github.com/users/drbyte","html_url":"https://github.com/drbyte","followers_url":"https://api.github.com/users/drbyte/followers","following_url":"https://api.github.com/users/drbyte/following{/other_user}","gists_url":"https://api.github.com/users/drbyte/gists{/gist_id}","starred_url":"https://api.github.com/users/drbyte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drbyte/subscriptions","organizations_url":"https://api.github.com/users/drbyte/orgs","repos_url":"https://api.github.com/users/drbyte/repos","events_url":"https://api.github.com/users/drbyte/events{/privacy}","received_events_url":"https://api.github.com/users/drbyte/received_events","type":"User","site_admin":false},"created_at":"2017-10-17T14:14:05Z","updated_at":"2017-10-17T14:14:05Z","author_association":"COLLABORATOR","body":"Ya, the `romanbican` package has the extra numeric `level` tier which can be used as you describe.\r\nThat package isn't maintained anymore, but `ultraware/roles` is a newer and maintained fork of it.\r\n\r\nI was toying with the idea of adding that sort of feature to this spatie package, but the project I was considering it for got canceled, so I don't need the feature now, and didn't write code for it."}}
{"actor":{"display_login":"drbyte"}}