Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ShiftResource | |
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 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Engelsystem\Controllers\Api\Resources; |
| 6 | |
| 7 | use Engelsystem\Models\BaseModel; |
| 8 | use Engelsystem\Models\Shifts\Shift; |
| 9 | use Illuminate\Contracts\Support\Arrayable; |
| 10 | use Illuminate\Database\Eloquent\Relations\Pivot; |
| 11 | use Illuminate\Support\Collection; |
| 12 | |
| 13 | class ShiftResource extends BasicResource |
| 14 | { |
| 15 | protected Collection | BaseModel | Pivot | Shift $model; |
| 16 | |
| 17 | public function toArray(array | Arrayable $location = []): array |
| 18 | { |
| 19 | return [ |
| 20 | 'id' => $this->model->id, |
| 21 | 'name' => $this->model->title, |
| 22 | 'description' => $this->model->description, |
| 23 | 'starts_at' => $this->model->start, |
| 24 | 'ends_at' => $this->model->end, |
| 25 | 'location' => LocationResource::toIdentifierArray($location), |
| 26 | 'shift_type' => ShiftTypeResource::toIdentifierArray($this->model->shiftType), |
| 27 | 'schedule_guid' => $this->model->scheduleShift?->guid, |
| 28 | 'created_at' => $this->model->created_at, |
| 29 | 'updated_at' => $this->model->updated_at, |
| 30 | 'url' => url('/shifts', ['action' => 'view', 'shift_id' => $this->model->id]), |
| 31 | ]; |
| 32 | } |
| 33 | } |