Conditions | 1 |
Paths | 1 |
Total Lines | 21 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | public function toArray($request) |
||
10 | { |
||
11 | return [ |
||
12 | 'id' => $this->id, |
||
|
|||
13 | 'parent_product_id' => $this->product_id, |
||
14 | 'sku' => $this->code, |
||
15 | 'name' => $this->product->name, |
||
16 | 'short_description' => $this->product->short_description, |
||
17 | 'description' => $this->product->description, |
||
18 | 'price' => number_format($this->price, 2, '.', ''), |
||
19 | 'cost' => number_format($this->cost, 2, '.', ''), |
||
20 | 'category' => [ |
||
21 | 'id' => $this->product->category_id, |
||
22 | 'name' => $this->product->category->name |
||
23 | ], |
||
24 | 'attributes' => collect($this->variant)->map(function ($item) { |
||
25 | return [ |
||
26 | 'name' => $item->attribute->name, |
||
27 | 'option' => $item->option->value |
||
28 | ]; |
||
29 | })->values()->toArray() |
||
30 | ]; |
||
32 | } |