1 | <?php |
||
17 | class ImpersonationPolicy extends Policy |
||
18 | { |
||
19 | /* ----------------------------------------------------------------- |
||
20 | | Main Methods |
||
21 | | ----------------------------------------------------------------- |
||
22 | */ |
||
23 | |||
24 | /** |
||
25 | * Get the ability's prefix. |
||
26 | * |
||
27 | * @return string |
||
28 | */ |
||
29 | 174 | protected static function prefix(): string |
|
33 | |||
34 | /** |
||
35 | * Get the abilities. |
||
36 | * |
||
37 | * @return iterable |
||
38 | */ |
||
39 | 174 | public function abilities(): iterable |
|
57 | |||
58 | /* ----------------------------------------------------------------- |
||
59 | | Policies |
||
60 | | ----------------------------------------------------------------- |
||
61 | */ |
||
62 | |||
63 | /** |
||
64 | * Check if the current user can impersonate. |
||
65 | * |
||
66 | * @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable|\Illuminate\Foundation\Auth\User $user |
||
67 | * |
||
68 | * @return bool |
||
69 | */ |
||
70 | 36 | public function canImpersonate(User $user): bool |
|
78 | |||
79 | /** |
||
80 | * Check if the given user can be impersonated. |
||
81 | * |
||
82 | * @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable|\Illuminate\Foundation\Auth\User $user |
||
83 | * @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonated |
||
84 | * |
||
85 | * @return bool |
||
86 | */ |
||
87 | 36 | public function canBeImpersonated(User $user, Impersonatable $impersonated): bool |
|
95 | |||
96 | /* ----------------------------------------------------------------- |
||
97 | | Other Methods |
||
98 | | ----------------------------------------------------------------- |
||
99 | */ |
||
100 | |||
101 | /** |
||
102 | * Check if the impersonation is enabled. |
||
103 | * |
||
104 | * @return bool |
||
105 | */ |
||
106 | 36 | private function isEnabled() |
|
110 | } |
||
111 |