Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
InputProductResource
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 toArray
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Domain\Product\Resources;
4
5use App\Models\Integration\Integration;
6use Domain\Category\Resources\FamilyResource;
7use Domain\Integration\Resources\IntegrationResource;
8use Domain\UnitMeasurement\Resources\UnitMeasurementResource;
9use Illuminate\Database\Eloquent\Model;
10use Illuminate\Http\Request;
11use Illuminate\Http\Resources\Json\JsonResource;
12
13/**
14 * @property string $integration_date
15 * @property string $integration_barcode
16 * @property string $integration_code
17 * @property int $id
18 * @property Model|null $pivot
19 * @property string $description
20 * @property mixed $integration_product
21 * @property Integration $integration
22 */
23class InputProductResource extends JsonResource
24{
25
26    public function toArray(Request $request): array
27    {
28        return [
29            'id' => $this->id,
30            'description' => $this->description,
31            'amount' => $this->amount,
32            'transferable_id' => $this->transferable_id,
33            'integration' => IntegrationResource::make($this->whenLoaded('integration')),
34            'measure' => ProductMeasureResource::make($this->whenLoaded('measure')),
35            'family' => FamilyResource::make($this->whenLoaded('family')),
36            'unit_measurement' => UnitMeasurementResource::make($this->whenLoaded('unitMeasurement')),
37        ];
38    }
39
40}