]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/Api/ApiController.php
Extend /users API endpoint
[bookstack] / app / Http / Controllers / Api / ApiController.php
1 <?php namespace BookStack\Http\Controllers\Api;
2
3 use BookStack\Api\ListingResponseBuilder;
4 use BookStack\Http\Controllers\Controller;
5 use Illuminate\Database\Eloquent\Builder;
6 use Illuminate\Http\JsonResponse;
7
8 abstract class ApiController extends Controller
9 {
10
11     protected $rules = [];
12     protected $printHidden = [];
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, array $protectedFieldsToPrint = []): JsonResponse
19     {
20         $listing = new ListingResponseBuilder($query, request(), $fields, $protectedFieldsToPrint);
21         return $listing->toResponse();
22     }
23
24     /**
25      * Get the validation rules for this controller.
26      */
27     public function getValdationRules(): array
28     {
29         return $this->rules;
30     }
31 }