Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
LocationsController
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 index
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Controllers\Api;
6
7use Engelsystem\Controllers\Api\Resources\LocationResource;
8use Engelsystem\Http\Response;
9use Engelsystem\Models\Location;
10
11class LocationsController extends ApiController
12{
13    public function index(): Response
14    {
15        $models = Location::query()
16            ->orderBy('name')
17            ->get();
18
19        $data = ['data' => LocationResource::collection($models)];
20        return $this->response
21            ->withContent(json_encode($data));
22    }
23}