File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 33namespace App\Contracts;
44
55use App\Interfaces\IAction;
6+ use App\Models\User;
67
78abstract class Action implements IAction
89{
9- # Блокировка инстанцирования
10- final private function __construct() {}
10+ /**
11+ * Пользователь, который вызвал этот Action
12+ */
13+ protected ?User $user;
14+
15+ final public function __construct()
16+ {
17+ $this->user = $this->authorize();
18+ }
19+
20+ /**
21+ * Проверяет, есть ли у пользователя доступ к этому Action
22+ */
23+ public function authorize(): ?User
24+ {
25+ return null;
26+ }
1127}
Original file line number Diff line number Diff line change 22
33namespace App\Interfaces;
44
5+ use App\Models\User;
6+
57interface IAction
68{
7-
9+ public function authorize(): ?User;
810}
Original file line number Diff line number Diff line change 33namespace {{ namespace }};
44
55use {{ rootNamespace }}Contracts\Action;
6+ use App\Models\User;
67
78/**
89 *
910 */
1011final class {{ class }} extends Action
1112{
13+ public function authorize(): ?User
14+ {
15+ //
16+ }
17+
1218 /**
1319 *
1420 */
15- public static function run() : array
21+ public function run() : array
1622 {
1723 return [];
1824 }
You can’t perform that action at this time.
0 commit comments