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 | 168 | protected static function prefix(): string |
|
33 | |||
34 | 168 | public function abilities(): iterable |
|
52 | |||
53 | /* ----------------------------------------------------------------- |
||
54 | | Policies |
||
55 | | ----------------------------------------------------------------- |
||
56 | */ |
||
57 | |||
58 | /** |
||
59 | * Check if the current user can impersonate. |
||
60 | * |
||
61 | * @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable|\Illuminate\Foundation\Auth\User $user |
||
62 | * |
||
63 | * @return bool |
||
64 | */ |
||
65 | 36 | public function canImpersonate(User $user): bool |
|
73 | |||
74 | /** |
||
75 | * Check if the given user can be impersonated. |
||
76 | * |
||
77 | * @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable|\Illuminate\Foundation\Auth\User $user |
||
78 | * @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonated |
||
79 | * |
||
80 | * @return bool |
||
81 | */ |
||
82 | 36 | public function canBeImpersonated(User $user, Impersonatable $impersonated): bool |
|
90 | |||
91 | /* ----------------------------------------------------------------- |
||
92 | | Other Methods |
||
93 | | ----------------------------------------------------------------- |
||
94 | */ |
||
95 | |||
96 | /** |
||
97 | * Check if the impersonation is enabled. |
||
98 | * |
||
99 | * @return bool |
||
100 | */ |
||
101 | 36 | private function isEnabled() |
|
105 | } |
||
106 |