1 | <?php |
||||
2 | |||||
3 | namespace Yeelight\Transformers; |
||||
4 | |||||
5 | use Yeelight\Models\AdminMenu; |
||||
6 | |||||
7 | /** |
||||
8 | * Class AdminMenuTransformer |
||||
9 | * |
||||
10 | * @category Yeelight |
||||
11 | * |
||||
12 | * @package Yeelight\Transformers |
||||
13 | * |
||||
14 | * @author Sheldon Lee <[email protected]> |
||||
15 | * |
||||
16 | * @license https://opensource.org/licenses/MIT MIT |
||||
17 | * |
||||
18 | * @link https://www.yeelight.com |
||||
19 | */ |
||||
20 | class AdminMenuTransformer extends BaseTransformer |
||||
21 | { |
||||
22 | /** |
||||
23 | * Transform the AdminMenu entity. |
||||
24 | * |
||||
25 | * @param AdminMenu $model |
||||
26 | * |
||||
27 | * @return array |
||||
28 | */ |
||||
29 | public function transform(AdminMenu $model) |
||||
30 | { |
||||
31 | return [ |
||||
32 | 'id' => (int) $model->id, |
||||
33 | 'parent_id' => (int) $model->parent_id, |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||
34 | 'order' => (int) $model->order, |
||||
0 ignored issues
–
show
The property
order does not exist on Yeelight\Models\AdminMenu . Since you implemented __get , consider adding a @property annotation.
Loading history...
|
|||||
35 | 'title' => (string) $model->title, |
||||
0 ignored issues
–
show
The property
title does not exist on Yeelight\Models\AdminMenu . Since you implemented __get , consider adding a @property annotation.
Loading history...
|
|||||
36 | 'icon' => (string) $model->icon, |
||||
0 ignored issues
–
show
The property
icon does not exist on Yeelight\Models\AdminMenu . Since you implemented __get , consider adding a @property annotation.
Loading history...
|
|||||
37 | 'uri' => (string) $model->uri, |
||||
0 ignored issues
–
show
The property
uri does not exist on Yeelight\Models\AdminMenu . Since you implemented __get , consider adding a @property annotation.
Loading history...
|
|||||
38 | 'roles' => (array) $model->roles, |
||||
0 ignored issues
–
show
The property
roles does not exist on Yeelight\Models\AdminMenu . Since you implemented __get , consider adding a @property annotation.
Loading history...
|
|||||
39 | 'role_ids' => (array) $model->roles->pluck($model->getKeyName())->toArray(), |
||||
0 ignored issues
–
show
The method
pluck() does not exist on null .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||
40 | 'roles_str' => (string) $this->getRolesAttr($model), |
||||
41 | 'created_at' => (string) $model->created_at, |
||||
42 | 'updated_at' => (string) $model->updated_at, |
||||
43 | ]; |
||||
44 | } |
||||
45 | |||||
46 | public function getRolesAttr(AdminMenu $model) |
||||
47 | { |
||||
48 | $roles = "<div style='margin-bottom: 5px;'>"; |
||||
49 | $roles .= collect($model->roles)->map(function ($role, $index) { |
||||
0 ignored issues
–
show
The property
roles does not exist on Yeelight\Models\AdminMenu . Since you implemented __get , consider adding a @property annotation.
Loading history...
|
|||||
50 | $br = $index && $index % 3 == 0 ? '</div><div style=\'margin-bottom: 5px;\'>' : ''; |
||||
51 | |||||
52 | return "<span class='label label-success'>{$role->name}</span>{$br}"; |
||||
53 | })->implode(' '); |
||||
54 | $roles .= '</div>'; |
||||
55 | |||||
56 | return $roles; |
||||
57 | } |
||||
58 | } |
||||
59 |