PHPackages                             archey347/uf\_altpermissions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. archey347/uf\_altpermissions

ActiveUserfrosting-sprinkle[Authentication &amp; Authorization](/categories/authentication)

archey347/uf\_altpermissions
============================

Alternate/complementary permission system for UserFrosting V4

v0.0.1(6y ago)07MITPHPPHP &gt;=5.6

Since Oct 25Pushed 4y agoCompare

[ Source](https://github.com/archey347/UF_AltPermissions)[ Packagist](https://packagist.org/packages/archey347/uf_altpermissions)[ Docs](https://github.com/lcharette/UF-AltPermissions)[ RSS](/packages/archey347-uf-altpermissions/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (8)Used By (0)

AltPermission Sprinkle for [UserFrosting 4](https://www.userfrosting.com)
=========================================================================

[](#altpermission-sprinkle-for-userfrosting-4)

[![Build Status](https://github.com/lcharette/UF_AltPermissions/workflows/Build/badge.svg?branch=master)](https://github.com/lcharette/UF_AltPermissions/actions?query=workflow%3ABuild) [![StyleCI](https://camo.githubusercontent.com/72bccf8c1bd5e78add16c93e832bfc652b8dc57a7cbc3971bbabdd24ba18b40b/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f38363130303734332f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/86100743) [![UserFrosting Version](https://camo.githubusercontent.com/ca87d65cf4076d8420d7d5a03aca46d7b8b4aa2d0c9d64e03846b37add3461ee/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5573657246726f7374696e672d2533453d253230342e322d627269676874677265656e2e737667)](https://github.com/userfrosting/UserFrosting) [![Donate](https://camo.githubusercontent.com/31745f59b96773962b48e7233400a30f0ebb7fae286d9c599d677beedb30425c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d4275792532304d6525323061253230436f666665652d627269676874677265656e2e737667)](https://ko-fi.com/A7052ICP)

Alternate/complementary permission system for [UserFrosting 4](https://www.userfrosting.com)

> This sprinkle is still a work in progress and not ready yet for production use. No official release has been made yet. Fell free to test it and contribute, or use it as a reference.

Help and Contributing
=====================

[](#help-and-contributing)

If you need help using this sprinkle or found any bug, feels free to open an issue or submit a pull request. You can also find me on the [UserFrosting Chat](https://chat.userfrosting.com/) most of the time for direct support.

Installation
============

[](#installation)

Edit UserFrosting `app/sprinkles/sprinkles.json` file and add the following to the `require` list :

```
"lcharette/UF_AltPermissions": "dev-master"

```

Run `composer update` then `composer run-script bake` to install the sprinkle.

Usage
=====

[](#usage)

Permission Slug Inheritance
---------------------------

[](#permission-slug-inheritance)

If you have a collection of permisisons of actions that are available on a page, you can group these together using dot-delimiter.

For example, if you have a page that allows you to manage a team, you might have the permissions `team.view`, `team.edit`, `team.delete`. Then, to test access to the page, you can do `hasPermission('team')` rather than having to test for each permission.`

Alternative to above
--------------------

[](#alternative-to-above)

The above system would cause problems if you had two permissions within the same namespace but had different seeker types. Instead, it would be better to have a common permission shared by all which you can just test instead.

Seeker Parents/Children
=======================

[](#seeker-parentschildren)

This allows for a permission and a role that have different seekers to be associated with each other.

For example, you may have a scenario where you have multiple organisations, and there are multiple teams inside each organisation. You may need to give some people access to all of the teams in an individual organisation, and then others just access to individual teams. You could do this by having a `team.view` permission that has a seeker type, `team`, and then a role called `Organisation Manager` that has seeker type `organisation`. Then, you would have to mofify the organisation and team models to tell the access control layer that there is a parent/child relationship.

```
class Organisation extends Model implements IPermissionParent
{
    protected $table = 'organisations';

    protected function getChildren($seekerType) {
        if($seekerType == 'team') {
            return $this->teams();
        }
    }

    protected function teams() {
        return $this->hasMany('...Models\Team');
    }

    ...
}

class Team extends Model implements IPermissionChild
{
    $table_name = 'teams';

    protected function getChildren($seekerType) {
        if($seekerType == 'team') {
            return $this->teams();
        }
    }

    protected function teams() {
        return $this->hasMany('...Models\Team');
    }

    ...
}
```

If you have a scenario where you have 3 layers of hierarchy, you have to expllicitly describe the relationship between all three, as the system isn't clever enough (yet!) to figure this out on it's own. The lines represent where child/parent relationships have been declared in the models.

```
Companies
