Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| LocationsController | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| index | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Engelsystem\Controllers; |
| 6 | |
| 7 | use Engelsystem\Http\Response; |
| 8 | use Engelsystem\Models\Location; |
| 9 | |
| 10 | class LocationsController extends BaseController |
| 11 | { |
| 12 | use HasUserNotifications; |
| 13 | |
| 14 | /** @var array<string> */ |
| 15 | protected array $permissions = [ |
| 16 | 'locations.view', |
| 17 | ]; |
| 18 | |
| 19 | public function __construct( |
| 20 | protected Location $location, |
| 21 | protected Response $response |
| 22 | ) { |
| 23 | } |
| 24 | |
| 25 | public function index(): Response |
| 26 | { |
| 27 | $locations = $this->location |
| 28 | ->withCount('shifts') |
| 29 | ->orderBy('name') |
| 30 | ->get(); |
| 31 | |
| 32 | return $this->response->withView( |
| 33 | 'pages/locations/index', |
| 34 | [ |
| 35 | 'locations' => $locations, |
| 36 | 'is_index' => true, |
| 37 | ] |
| 38 | ); |
| 39 | } |
| 40 | } |