Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ShiftResource | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
toArray | |
100.00% |
12 / 12 |
|
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\Support\Collection; |
11 | |
12 | class ShiftResource extends BasicResource |
13 | { |
14 | protected Collection | BaseModel | Shift $model; |
15 | |
16 | public function toArray(array | Arrayable $location = []): array |
17 | { |
18 | return [ |
19 | 'id' => $this->model->id, |
20 | 'name' => $this->model->title, |
21 | 'description' => $this->model->description, |
22 | 'starts_at' => $this->model->start, |
23 | 'ends_at' => $this->model->end, |
24 | 'location' => LocationResource::toIdentifierArray($location), |
25 | 'shift_type' => ShiftTypeResource::toIdentifierArray($this->model->shiftType), |
26 | 'created_at' => $this->model->created_at, |
27 | 'updated_at' => $this->model->updated_at, |
28 | 'url' => url('/shifts', ['action' => 'view', 'shift_id' => $this->model->id]), |
29 | ]; |
30 | } |
31 | } |