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