1 | <?php |
||
2 | |||
3 | namespace Ronmrcdo\Inventory\Resources; |
||
4 | |||
5 | use Illuminate\Http\Resources\Json\JsonResource; |
||
6 | |||
7 | class VariantResource extends JsonResource |
||
8 | { |
||
9 | public function toArray($request) |
||
10 | { |
||
11 | return [ |
||
12 | 'id' => $this->id, |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
13 | 'parent_product_id' => $this->product_id, |
||
0 ignored issues
–
show
The property
product_id does not exist on Ronmrcdo\Inventory\Resources\VariantResource . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
14 | 'sku' => $this->code, |
||
0 ignored issues
–
show
The property
code does not exist on Ronmrcdo\Inventory\Resources\VariantResource . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
15 | 'name' => $this->product->name, |
||
0 ignored issues
–
show
The property
product does not exist on Ronmrcdo\Inventory\Resources\VariantResource . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
16 | 'short_description' => $this->product->short_description, |
||
17 | 'description' => $this->product->description, |
||
18 | 'price' => number_format($this->price, 2, '.', ''), |
||
0 ignored issues
–
show
The property
price does not exist on Ronmrcdo\Inventory\Resources\VariantResource . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
19 | 'cost' => number_format($this->cost, 2, '.', ''), |
||
0 ignored issues
–
show
The property
cost does not exist on Ronmrcdo\Inventory\Resources\VariantResource . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
20 | 'category' => [ |
||
21 | 'id' => $this->product->category_id, |
||
22 | 'name' => $this->product->category->name |
||
23 | ], |
||
24 | 'attributes' => collect($this->variant)->map(function ($item) { |
||
0 ignored issues
–
show
The property
variant does not exist on Ronmrcdo\Inventory\Resources\VariantResource . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
25 | return [ |
||
26 | 'name' => $item->attribute->name, |
||
27 | 'option' => $item->option->value |
||
28 | ]; |
||
29 | })->values()->toArray() |
||
30 | ]; |
||
31 | } |
||
32 | } |