1 | <?php |
||
5 | trait HasAccess |
||
6 | { |
||
7 | /** |
||
8 | * @var \Illuminate\Support\Collection |
||
9 | */ |
||
10 | private static $abilities; |
||
11 | |||
12 | protected static $observer = \Sco\Admin\Component\Observer::class; |
||
13 | |||
14 | protected $observables = []; |
||
15 | |||
16 | public static function bootHasAccess() |
||
22 | |||
23 | public function isView() |
||
27 | |||
28 | public function isCreate() |
||
32 | |||
33 | public function isEdit() |
||
37 | |||
38 | public function isDelete() |
||
42 | |||
43 | public function isDestroy() |
||
47 | |||
48 | public function isRestore() |
||
52 | |||
53 | protected function isRestorableModel() |
||
57 | |||
58 | public static function observe($class) |
||
73 | |||
74 | /** |
||
75 | * Get the observable event names. |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | public function getObservableAbilities() |
||
89 | |||
90 | public function registerAccess($ability, $callback) |
||
94 | |||
95 | /** |
||
96 | * @param string $ability |
||
97 | * |
||
98 | * @return mixed |
||
99 | */ |
||
100 | final public function can($ability) |
||
114 | } |
||
115 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: