Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ShiftResource
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toArray
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Controllers\Api\Resources;
6
7use Engelsystem\Models\BaseModel;
8use Engelsystem\Models\Shifts\Shift;
9use Illuminate\Contracts\Support\Arrayable;
10use Illuminate\Support\Collection;
11
12class 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}