1 | <?php namespace Arcanesoft\Auth\Models; |
||
16 | class User extends BaseUserModel implements Impersonatable |
||
|
|||
17 | { |
||
18 | /* ----------------------------------------------------------------- |
||
19 | | Traits |
||
20 | | ----------------------------------------------------------------- |
||
21 | */ |
||
22 | |||
23 | use Presenters\UserPresenter, |
||
24 | CanImpersonate; |
||
25 | |||
26 | /* ----------------------------------------------------------------- |
||
27 | | Relationships |
||
28 | | ----------------------------------------------------------------- |
||
29 | */ |
||
30 | |||
31 | /** |
||
32 | * Password reset relationship. |
||
33 | * |
||
34 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
35 | */ |
||
36 | public function passwordReset() |
||
40 | |||
41 | /* ----------------------------------------------------------------- |
||
42 | | Scopes |
||
43 | | ----------------------------------------------------------------- |
||
44 | */ |
||
45 | |||
46 | /** |
||
47 | * Protect admins. |
||
48 | * |
||
49 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
50 | * |
||
51 | * @return \Illuminate\Database\Eloquent\Builder |
||
52 | */ |
||
53 | public function scopeProtectAdmins(Builder $query) |
||
62 | |||
63 | /* ----------------------------------------------------------------- |
||
64 | | Main Methods |
||
65 | | ----------------------------------------------------------------- |
||
66 | */ |
||
67 | |||
68 | /** |
||
69 | * Get a user from a hashed id or fail if not found. |
||
70 | * |
||
71 | * @param string $hashedId |
||
72 | * |
||
73 | * @return self |
||
74 | * |
||
75 | * @throws \Illuminate\Database\Eloquent\ModelNotFoundException |
||
76 | */ |
||
77 | public static function firstHashedOrFail($hashedId) |
||
81 | |||
82 | /* ----------------------------------------------------------------- |
||
83 | | Check Methods |
||
84 | | ----------------------------------------------------------------- |
||
85 | */ |
||
86 | |||
87 | /** |
||
88 | * Check if user is an administrator. |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | public function isAdmin() |
||
96 | |||
97 | /** |
||
98 | * Check if user is a moderator. |
||
99 | * |
||
100 | * @return bool |
||
101 | */ |
||
102 | public function isModerator() |
||
106 | |||
107 | /** |
||
108 | * Check if user is a member. |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function isMember() |
||
116 | |||
117 | /** |
||
118 | * Check if user has a password reset. |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | public function hasPasswordReset() |
||
126 | |||
127 | /** |
||
128 | * Check if the current modal can impersonate other models. |
||
129 | * |
||
130 | * @return bool |
||
131 | */ |
||
132 | public function canImpersonate() |
||
136 | |||
137 | /** |
||
138 | * Check if the current model can be impersonated. |
||
139 | * |
||
140 | * @return bool |
||
141 | */ |
||
142 | public function canBeImpersonated() |
||
146 | } |
||
147 |