X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c429cf78187e80deb63982a282a1c6889f30291a..663f81a2b1eba75883fbab6577a386351b86f623:/app/Http/Controllers/Api/BookApiController.php diff --git a/app/Http/Controllers/Api/BookApiController.php b/app/Http/Controllers/Api/BookApiController.php index abe23f45d..73cac6318 100644 --- a/app/Http/Controllers/Api/BookApiController.php +++ b/app/Http/Controllers/Api/BookApiController.php @@ -11,19 +11,6 @@ class BookApiController extends ApiController { protected $bookRepo; - protected $rules = [ - 'create' => [ - 'name' => 'required|string|max:255', - 'description' => 'string|max:1000', - 'tags' => 'array', - ], - 'update' => [ - 'name' => 'string|min:1|max:255', - 'description' => 'string|max:1000', - 'tags' => 'array', - ], - ]; - public function __construct(BookRepo $bookRepo) { $this->bookRepo = $bookRepo; @@ -37,7 +24,7 @@ class BookApiController extends ApiController $books = Book::visible(); return $this->apiListingResponse($books, [ - 'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by', 'image_id', + 'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by', ]); } @@ -97,4 +84,21 @@ class BookApiController extends ApiController return response('', 204); } + + protected function rules(): array { + return [ + 'create' => [ + 'name' => ['required', 'string', 'max:255'], + 'description' => ['string', 'max:1000'], + 'tags' => ['array'], + 'image' => array_merge(['nullable'], $this->getImageValidationRules()), + ], + 'update' => [ + 'name' => ['string', 'min:1', 'max:255'], + 'description' => ['string', 'max:1000'], + 'tags' => ['array'], + 'image' => array_merge(['nullable'], $this->getImageValidationRules()), + ], + ]; + } }