Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
UserResource
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toArray
100.00% covered (success)
100.00%
9 / 9
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\User\User;
9use Illuminate\Support\Collection;
10
11class UserResource extends BasicResource
12{
13    protected Collection | BaseModel | User $model;
14
15    public function toArray(): array
16    {
17        return [
18            'id' => $this->model->id,
19            'name' => $this->model->name,
20            'first_name' => $this->model->personalData->first_name,
21            'last_name' => $this->model->personalData->last_name,
22            'pronoun' => $this->model->personalData->pronoun,
23            'contact' => $this->model->contact->only(['dect', 'mobile']),
24            'url' => url('/users', ['action' => 'view', 'user_id' => $this->model->id]),
25        ];
26    }
27}