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