]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/Api/ApiController.php
Apply fixes from StyleCI
[bookstack] / app / Http / Controllers / Api / ApiController.php
1 <?php
2
3 namespace BookStack\Http\Controllers\Api;
4
5 use BookStack\Api\ListingResponseBuilder;
6 use BookStack\Http\Controllers\Controller;
7 use Illuminate\Database\Eloquent\Builder;
8 use Illuminate\Http\JsonResponse;
9
10 abstract class ApiController extends Controller
11 {
12     protected $rules = [];
13
14     /**
15      * Provide a paginated listing JSON response in a standard format
16      * taking into account any pagination parameters passed by the user.
17      */
18     protected function apiListingResponse(Builder $query, array $fields): JsonResponse
19     {
20         $listing = new ListingResponseBuilder($query, request(), $fields);
21
22         return $listing->toResponse();
23     }
24
25     /**
26      * Get the validation rules for this controller.
27      */
28     public function getValdationRules(): array
29     {
30         return $this->rules;
31     }
32 }