1 | <?php |
||
2 | |||
3 | namespace App\Http\Resources; |
||
4 | |||
5 | use Illuminate\Http\Resources\Json\JsonResource; |
||
6 | |||
7 | class GalaxyResource extends JsonResource |
||
8 | { |
||
9 | /** |
||
10 | * @param \Illuminate\Http\Request $request |
||
11 | * @return array |
||
12 | */ |
||
13 | public function toArray($request) |
||
14 | { |
||
15 | $galaxies = [ |
||
16 | 'galaxy_id' => $this->id, |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
17 | 'galaxy_type' => $this->type->name, |
||
0 ignored issues
–
show
The property
type does not exist on App\Http\Resources\GalaxyResource . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
18 | 'name' => $this->display_name, |
||
0 ignored issues
–
show
The property
display_name does not exist on App\Http\Resources\GalaxyResource . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
19 | 'updated_at' => $this->updated_at->format('Y-m-d H:m:s'), |
||
0 ignored issues
–
show
The property
updated_at does not exist on App\Http\Resources\GalaxyResource . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
20 | ]; |
||
21 | |||
22 | if (!empty($this->worlds)) { |
||
0 ignored issues
–
show
The property
worlds does not exist on App\Http\Resources\GalaxyResource . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
23 | $galaxies['worlds'] = WorldResource::collection($this->worlds); |
||
24 | } |
||
25 | |||
26 | return $galaxies; |
||
27 | } |
||
28 | } |