Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
RequestItemResource
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toArray
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Domain\Request\Resources;
4
5use Illuminate\Http\Request;
6use Illuminate\Http\Resources\Json\JsonResource;
7
8use Domain\Product\Resources\ProductResource;
9use Domain\StockIO\Resources\StockIOProductResource;
10
11/**
12 * @property int $id
13 * @property ProductResource $product
14 * @property float $amount
15 * @property string $created_at
16 * @property string $updated_at
17 */
18class RequestItemResource extends JsonResource
19{
20
21    public function toArray(Request $request): array
22    {
23        return [
24            'id'               => $this->id,
25            'product'          => ProductResource::make($this->whenLoaded('product')),
26            'stock_io_product' => StockIOProductResource::make($this->whenLoaded('stockIoProduct')),
27            'amount'           => $this->amount,
28            'status'           => $this->status?->value,
29            'created_at'       => (string)$this->created_at,
30            'updated_at'       => (string)$this->updated_at,
31        ];
32    }
33}