spotonlive / sl-entrust-doctrine-orm
Doctrine2 ORM - Zizco Entrust (Laravel 5.1) for Zizco Entrust
Installs: 1 678
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 2
Open Issues: 1
Requires
- php: >=5.4.0
- ramsey/uuid: 2.8.*
- zizaco/entrust: ~1.4.1
Requires (Dev)
- doctrine/orm: ~2.5.1
- laravel/framework: ~5.1
- mockery/mockery: ~0.9.4
- phpunit/phpunit: ~4.0
- ramsey/uuid: 2.8.*
- zizaco/entrust: ~1.4.1
This package is not auto-updated.
Last update: 2024-12-21 20:08:29 UTC
README
THIS PACKAGE IS UNDER DEVELOPMENT
Configuration
Installation
Run $ composer require spotonlive/sl-entrust-doctrine-orm
config/app.php
'providers' => [
(...)
SpotOnLive\EntrustDoctrineORM\EntrustDoctrineORMServiceProvider::class,
'Zizaco\Entrust\EntrustServiceProvider',
(...)
]
'aliases' => [
(...)
'Entrust' => 'Zizaco\Entrust\EntrustFacade'
(...)
]
User.php
use Doctrine\Common\Collections\ArrayCollection; class User implements \SpotOnLive\EntrustDoctrineORM\Entities\UserRoleInterface { /** * @var \SpotOnLive\EntrustDoctrineORM\Entities\RoleInterface[]|ArrayCollection * * @ORM\ManyToMany(targetEntity="SpotOnLive\EntrustDoctrineORM\Entities\Role") * @ORM\JoinTable(name="user_role_linker", * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")} * ) **/ protected $roles; public function __construct() { $this->roles = new ArrayCollection(); } /** * @return ArrayCollection|\SpotOnLive\EntrustDoctrineORM\Entities\RoleInterface[] */ public function getRoles() { return $this->roles; } /** * @param ArrayCollection|\SpotOnLive\EntrustDoctrineORM\Entities\RoleInterface[] $roles */ public function setRoles($roles) { $this->roles = $roles; } /** * @param \SpotOnLive\EntrustDoctrineORM\Entities\RoleInterface[] $roles */ public function addRoles($roles) { $this->roles->add($roles); } /** * @param \SpotOnLive\EntrustDoctrineORM\Entities\RoleInterface[] $roles */ public function removeRoles($roles) { $this->roles->remove($roles); } (...) }
Traits
Use \SpotOnLive\EntrustDoctrineORM\Traits\EntrustDoctrineORMUserTrait
in your entity.
Migrations
- Difference:
$ vendor/bin/doctrine-laravel migrations:diff
- Migrate:
$ vendor/bin/doctrine-laravel migrations:migrate