]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/Api/ApiController.php
Added webhook_call_before theme event hook
[bookstack] / app / Http / Controllers / Api / ApiController.php
index 65a5bb99f6ca3bfc6f99e4e0137d4e6029d91ff3..3f049a08c8afaba8523448137624b80dc078a0d1 100644 (file)
@@ -1,13 +1,14 @@
-<?php namespace BookStack\Http\Controllers\Api;
+<?php
+
+namespace BookStack\Http\Controllers\Api;
 
 use BookStack\Api\ListingResponseBuilder;
 use BookStack\Http\Controllers\Controller;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\JsonResponse;
 
-class ApiController extends Controller
+abstract class ApiController extends Controller
 {
-
     protected $rules = [];
 
     /**
@@ -17,14 +18,20 @@ class ApiController extends Controller
     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;
     }
-}
\ No newline at end of file
+}