Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| NewsResource | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
11 / 11 |
|
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\News; |
| 9 | use Illuminate\Database\Eloquent\Relations\Pivot; |
| 10 | use Illuminate\Support\Collection; |
| 11 | |
| 12 | class NewsResource extends BasicResource |
| 13 | { |
| 14 | protected Collection | BaseModel | Pivot | News $model; |
| 15 | |
| 16 | public function toArray(): array |
| 17 | { |
| 18 | return [ |
| 19 | 'id' => $this->model->id, |
| 20 | 'name' => $this->model->title, |
| 21 | 'text' => $this->model->text, |
| 22 | 'is_meeting' => $this->model->is_meeting, |
| 23 | 'is_pinned' => $this->model->is_pinned, |
| 24 | 'is_highlighted' => $this->model->is_highlighted, |
| 25 | 'created_at' => $this->model->created_at, |
| 26 | 'updated_at' => $this->model->updated_at, |
| 27 | 'url' => url('/news/' . $this->model->id), |
| 28 | ]; |
| 29 | } |
| 30 | } |