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
PickingOrderProductResource
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\PickingOrder\Resources;
4
5use App\Models\User;
6use Domain\PickingOrder\Enums\PickingOrderTypeEnum;
7use Illuminate\Http\Request;
8use Illuminate\Http\Resources\Json\JsonResource;
9use Illuminate\Support\Carbon;
10use Illuminate\Support\Facades\Auth;
11
12/**
13 * @property bool $status
14 * @property Carbon $created_at
15 * @property ?Carbon $start_date
16 * @property ?Carbon $end_date
17 * @property int $id
18 * @property PickingOrderTypeEnum $type
19 */
20class PickingOrderProductResource extends JsonResource
21{
22    public function toArray(Request $request): array
23    {
24        /** @var User $user */
25        $user = Auth::user();
26
27        return [
28            'id'     => $this->id,
29            'status' => $this->status,
30            'amount' => $this->amount,
31            'type'   => $this->type,
32            'picking_order' => PickingOrderResource::make($this->whenLoaded('pickingOrder')),
33            'stockIOProduct' => OrderProductsResource::make($this->whenLoaded('stockIOProduct')),
34            'pickedItems' => PickedItemResource::collection($this->whenLoaded('pickedItems')),
35        ];
36    }
37}