Conditions | 5 |
Paths | 8 |
Total Lines | 19 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | public function toArray($request) |
||
18 | { |
||
19 | return [ |
||
20 | 'id' => $this->id, |
||
|
|||
21 | 'name' => $this->name, |
||
22 | 'slug' => $this->slug, |
||
23 | 'sku' => $this->hasSku() ? $this->skus()->first()->code : null, |
||
24 | 'short_description' => $this->short_description, |
||
25 | 'description' => $this->description, |
||
26 | 'price' => $this->hasSku() ? number_format($this->skus()->first()->price, 2, '.', '') : 0.00, |
||
27 | 'cost' => $this->hasSku() ? number_format($this->skus()->first()->price, 2, '.', '') : 0.00, |
||
28 | 'is_active' => $this->is_active, |
||
29 | 'category' => [ |
||
30 | 'id' => $this->category->id, |
||
31 | 'name' => $this->category->name |
||
32 | ], |
||
33 | 'attributes' => AttributeResource::collection($this->attributes)->toArray(app('request')), |
||
34 | 'variations' => $this->when($this->hasAttributes() && $this->hasSku(), |
||
35 | VariantResource::collection($this->skus)->toArray(app('request')) |
||
36 | ) |
||
39 | } |