Usage
HasRole trait
Laravel ACL package comes bundled with a HasRole
file to be used within your User
model file.
This trait provides all the necessary functions to tie your users in with roles and permissions.
Example User Model
<?php namespace App; use Illuminate\Foundation\Auth\User as Authenticatable;use Illuminate\Notifications\Notifiable;use Yajra\Acl\Traits\HasRole; class User extends Authenticatable{ use Notifiable; use HasRole; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'gender', 'email', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ];}
HasRoleAndPermission trait
Laravel ACL package comes bundled with a HasRoleAndPermission
file that can be used within your User
model.
This trait includes all the abilities we have on HasRole
trait with added functionalities that allows the User
to have its own custom set of permissions.
Example User Model
<?php namespace App; use Illuminate\Foundation\Auth\User as Authenticatable;use Illuminate\Notifications\Notifiable;use Yajra\Acl\Traits\HasRoleAndPermission; class User extends Authenticatable{ use Notifiable; use HasRoleAndPermission; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'gender', 'email', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ];}