Conditions | 6 |
Paths | 20 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | protected function getResourceVariables(?Model $model = null): array |
||
29 | { |
||
30 | $routePrefix = 'microboard'; |
||
31 | $translationsPrefix = ''; |
||
32 | |||
33 | if (property_exists($this, 'attributes')) { |
||
34 | if (isset($this->attributes['routes_prefix'])) { |
||
35 | $routePrefix = $this->attributes['routes_prefix']; |
||
36 | } |
||
37 | if (isset($this->attributes['translations_prefix'])) { |
||
38 | $translationsPrefix = $this->attributes['translations_prefix']; |
||
39 | } |
||
40 | } |
||
41 | |||
42 | return [ |
||
43 | 'resource' => $this->model, |
||
44 | 'resourceName' => Str::of($this->baseName)->lower()->plural(), |
||
45 | 'resourceVariable' => Str::of($this->baseName)->lower(), |
||
46 | 'routePrefix' => $routePrefix ? $routePrefix . '.' : '', |
||
47 | 'translationsPrefix' => $translationsPrefix ? $translationsPrefix . '::' : '', |
||
48 | 'model' => $model |
||
49 | ]; |
||
50 | } |
||
51 | } |
||
52 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: