2017 © Pedro Peláez
 

library usher

A Doctrine ACL package for Laravel

image

maatwebsite/usher

A Doctrine ACL package for Laravel

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 26 % Grown

The README.md

Usher

A Doctrine ACL package for Laravel 5

  • Login with Doctrine User entity
  • User roles
  • User banning
  • User suspending
  • User permissions
  • User last login and last attempt event listeners
  • Role permissions

Installation

Include the service provider in config/app.php, (*1)

'Brouwers\LaravelDoctrine\DoctrineServiceProvider',
'Maatwebsite\Usher\UsherServiceProvider'

Config

To change the defaults of this package, publish the config:, (*2)

php artisan vendor:publish --provider="Maatwebsite\Usher\UsherServiceProvider"

Default usage

Out of the box, you can use the ACL system without defining your own entities. However this is not recommended!, (*3)

Custom usage

For example if you want a Customer and Group entity, you just have to make sure it implements Maatwebsite\Usher\Contracts\Users\User. If you want a faster solution, you can optionally extend the MappedSuperclass Maatwebsite\Usher\Domain\Users\User. *Note that you will have to define the roles relation yourself., (*4)

Example with the MappedSuperclass:, (*5)


use Doctrine\ORM\Mapping as ORM; use Maatwebsite\Usher\Domain\Users\User; use Maatwebsite\Usher\Contracts\Users\User as UserInterface; /** * @ORM\Entity(repositoryClass="DoctrineCustomerRepository") * @ORM\Table(name="customers") * @ORM\HasLifecycleCallbacks() */ class Customer extends User implements UserInterface { /** * @ORM\ManyToMany(targetEntity="Group", inversedBy="customers") * @ORM\JoinTable(name="customer_groups") * @var ArrayCollection|\App\Domain\Customers\Entities\Role[] */ protected $groups; /** * Customer Constructor */ public function __construct() { $this->groups = new ArrayCollection(); } /** * @return ArrayCollection|\Maatwebsite\Usher\Contracts\Roles\Role[] */ public function getRoles() { return $this->groups; } }

Same as with the User MappedSuperclass, you'll have to define the User relation yourself., (*6)

/**
 * @ORM\Entity(repositoryClass="DoctrineRoleRepository")
 * @ORM\Table(name="groups")
 * @ORM\HasLifecycleCallbacks()
 */
class Group extends Role implements RoleInterface
{

    /**
     * @ORM\ManyToMany(targetEntity="Customer", mappedBy="groups")
     * @var ArrayCollection|Customer[]
     **/
    protected $customers;

    /**
     * Role Constructor
     */
    public function __construct()
    {
        $this->customers = new ArrayCollection();
    }

    /**
     * @return ArrayCollection|\Maatwebsite\Usher\Contracts\Users\User[]
     */
    public function getUsers()
    {
        return $this->customers;
    }
}

Next you'll have to update the class reference in config/usher.php for the user.entity en role.entity, (*7)

return [
    'users'  => [
        'entity' => 'Customer'
    ],
    'roles'  => [
        'entity' => 'Group'
    ]
]

Events

Domain Events

Domain Event When
UserGotAssignedToRole $user->assignRole($role)
UserGotBanned $user->ban()
UserGotRemovedFromRole $user->removeRole($role)
UserGotSuspended $user->suspend($minutes)
UserRegistered $user->register()
UserUpdatedProfile $user->update()
RoleWasCreated $role->create()
RoleWasUpdated $role->update()

Event Listeners

Event listeners can be enabled and disabled inside the config. By default the listed listenes are all enabled., (*8)

Listener When
SaveLastAttemptDate auth.attempt
CheckIfUserIsBanned auth.attempt
CheckIfUserIsSuspended auth.attempt
SaveLastLoginDate auth.login

The Versions

08/07 2015

dev-master

9999999-dev

A Doctrine ACL package for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maatwebsite.nl

orm laravel acl roles doctrine users

08/07 2015

1.0.1

1.0.1.0

A Doctrine ACL package for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maatwebsite.nl

orm laravel acl roles doctrine users

05/07 2015

1.0.0

1.0.0.0

A Doctrine ACL package for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maatwebsite.nl

orm laravel acl roles doctrine users

03/05 2015

dev-roles-eagerloading

dev-roles-eagerloading

A Doctrine ACL package for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maatwebsite.nl

orm laravel acl roles doctrine users