mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-02 22:03:48 +08:00
85154fff69
Replaces the old suggestion of setting JS head 'window.uploadLimit' variable. This new env option will be used by back-end validation and front-end libs/logic too. Limits already likely exist within prod environments at a PHP and webserver level but this allows an app-level limit and centralises the option on the BookStack side into the .env Closes #3033
38 lines
980 B
PHP
38 lines
980 B
PHP
<?php
|
|
|
|
namespace BookStack\Http\Controllers\Api;
|
|
|
|
use BookStack\Api\ListingResponseBuilder;
|
|
use BookStack\Http\Controllers\Controller;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
abstract class ApiController extends Controller
|
|
{
|
|
protected $rules = [];
|
|
|
|
/**
|
|
* Provide a paginated listing JSON response in a standard format
|
|
* taking into account any pagination parameters passed by the user.
|
|
*/
|
|
protected function apiListingResponse(Builder $query, array $fields): JsonResponse
|
|
{
|
|
$listing = new ListingResponseBuilder($query, request(), $fields);
|
|
|
|
return $listing->toResponse();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules for this controller.
|
|
* Defaults to a $rules property but can be a rules() method.
|
|
*/
|
|
public function getValdationRules(): array
|
|
{
|
|
if (method_exists($this, 'rules')) {
|
|
return $this->rules();
|
|
}
|
|
|
|
return $this->rules;
|
|
}
|
|
}
|