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