Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| TransferTaskResource | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\TransferTask\Resources; |
| 4 | |
| 5 | use Carbon\Carbon; |
| 6 | use Domain\Team\Resources\TeamResource; |
| 7 | use Domain\TransferTask\Enums\TransferTaskStatusEnum; |
| 8 | use Domain\User\Resources\UserSensitiveResource; |
| 9 | use Illuminate\Http\Request; |
| 10 | use Illuminate\Http\Resources\Json\JsonResource; |
| 11 | |
| 12 | /** |
| 13 | * @property Carbon $start_date |
| 14 | * @property Carbon $end_date |
| 15 | * @property TransferTaskStatusEnum $status |
| 16 | * @property string $observation |
| 17 | * @property String $created_at |
| 18 | * @property String $updated_at |
| 19 | * @property int $id |
| 20 | */ |
| 21 | class TransferTaskResource extends JsonResource |
| 22 | { |
| 23 | |
| 24 | public function toArray(Request $request): array |
| 25 | { |
| 26 | return [ |
| 27 | 'id' => $this->id, |
| 28 | 'products' => TransferTaskProductResource::collection($this->whenLoaded('TransferTaskProducts')), |
| 29 | 'responsible' => UserSensitiveResource::make($this->whenLoaded('responsible')), |
| 30 | 'team' => TeamResource::make($this->whenLoaded('team')), |
| 31 | 'start_date' => (string)$this->start_date, |
| 32 | 'end_date' => (string)$this->end_date, |
| 33 | 'status' => $this->status->value, |
| 34 | 'observation' => $this->observation, |
| 35 | 'created_by' => UserSensitiveResource::make($this->whenLoaded('creator')), |
| 36 | 'created_at' => (string)$this->created_at, |
| 37 | 'updated_at' => (string)$this->updated_at, |
| 38 | ]; |
| 39 | } |
| 40 | } |