1 | <?php |
||
9 | abstract class BaseUser extends Authenticatable |
||
10 | { |
||
11 | use Notifiable; |
||
12 | |||
13 | /** |
||
14 | * The attributes that are mass assignable. |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $fillable = [ |
||
19 | 'name', 'email', 'password', |
||
20 | ]; |
||
21 | |||
22 | /** |
||
23 | * The attributes that should be hidden for arrays. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $hidden = [ |
||
28 | 'password', 'remember_token', |
||
29 | ]; |
||
30 | |||
31 | /** |
||
32 | * Return all of the tenants this user is the owner of |
||
33 | */ |
||
34 | public function roles() |
||
43 | |||
44 | /** |
||
45 | * Assign a given role to a user |
||
46 | */ |
||
47 | public function assignRole(BaseRole $role) |
||
53 | |||
54 | /** |
||
55 | * Check if a user has a given role |
||
56 | */ |
||
57 | public function hasRole($role) |
||
77 | |||
78 | /** |
||
79 | * Return all of the tenants this user is the owner of |
||
80 | */ |
||
81 | public function owns() |
||
82 | { |
||
83 | return $this->hasMany(config('multi-tenant.tenant_class'), 'owner_id'); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Return the currently active tenant for this user based on the session |
||
88 | */ |
||
89 | public function activeTenant() |
||
93 | |||
94 | /** |
||
95 | * The tenants relationship |
||
96 | */ |
||
97 | public function tenants() |
||
101 | } |
||
102 |