1 | <?php |
||
26 | abstract class JsonApiController extends Controller |
||
27 | { |
||
28 | use JsonApiErrors; |
||
29 | use QueriesResources; |
||
30 | use UpdatesModelRelations; |
||
31 | use AuthorizesRequests; |
||
32 | use ValidatesRequests; |
||
33 | |||
34 | /** |
||
35 | * The Eloquent Model for the resource. |
||
36 | * |
||
37 | * @var Model|string |
||
38 | */ |
||
39 | protected $model; |
||
40 | |||
41 | /** |
||
42 | * Create a new JsonApiController instance. |
||
43 | */ |
||
44 | public function __construct() |
||
55 | |||
56 | /** |
||
57 | * Return a listing of the resource. |
||
58 | * |
||
59 | * @param Request $request |
||
60 | * @param \Illuminate\Database\Eloquent\Builder|null $query Custom resource query |
||
61 | * |
||
62 | * @return JsonApiResponse |
||
63 | */ |
||
64 | public function indexAction(Request $request, $query = null) |
||
82 | |||
83 | /** |
||
84 | * Store a new record. |
||
85 | * |
||
86 | * @param Request $request |
||
87 | * |
||
88 | * @return JsonApiResponse |
||
89 | */ |
||
90 | public function storeAction(Request $request) |
||
100 | |||
101 | /** |
||
102 | * Return a specified record. |
||
103 | * |
||
104 | * @param Request $request |
||
105 | * @param Model|mixed $record |
||
106 | * |
||
107 | * @return JsonApiResponse |
||
108 | */ |
||
109 | public function showAction(Request $request, $record) |
||
117 | |||
118 | /** |
||
119 | * Update a specified record. |
||
120 | * |
||
121 | * @param Request $request |
||
122 | * @param Model|mixed $record |
||
123 | * |
||
124 | * @return JsonApiResponse |
||
125 | */ |
||
126 | public function updateAction(Request $request, $record) |
||
138 | |||
139 | /** |
||
140 | * Destroy a specified record. |
||
141 | * |
||
142 | * @param Request $request |
||
143 | * @param Model|mixed $record |
||
144 | * |
||
145 | * @return JsonApiResponse |
||
146 | */ |
||
147 | public function destroyAction(Request $request, $record) |
||
154 | |||
155 | /** |
||
156 | * Return a specified record relationship. |
||
157 | * |
||
158 | * @param Request $request |
||
159 | * @param Model|mixed $record |
||
160 | * @param string $relation |
||
161 | * |
||
162 | * @return JsonApiResponse |
||
163 | */ |
||
164 | public function showRelationshipAction(Request $request, $record, $relation) |
||
170 | |||
171 | /** |
||
172 | * Update a named relationship on a specified record. |
||
173 | * |
||
174 | * http://jsonapi.org/format/#crud-updating-relationships |
||
175 | * |
||
176 | * @param Request $request |
||
177 | * @param Model|mixed $record |
||
178 | * @param string $relation |
||
179 | * |
||
180 | * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException |
||
181 | * |
||
182 | * @return JsonApiResponse |
||
183 | */ |
||
184 | public function updateRelationshipAction(Request $request, $record, $relation) |
||
200 | |||
201 | /** |
||
202 | * Return existing instance of the resource or find by primary key. |
||
203 | * |
||
204 | * @param Model|mixed $record |
||
205 | * |
||
206 | * @throws ModelNotFoundException |
||
207 | * |
||
208 | * @return Model |
||
209 | */ |
||
210 | protected function findModelInstance($record) |
||
222 | |||
223 | /** |
||
224 | * Return any JSON API resource parameters from a request. |
||
225 | * |
||
226 | * @param Request $request |
||
227 | * |
||
228 | * @return array |
||
229 | */ |
||
230 | protected function getRequestParameters($request) |
||
245 | |||
246 | /** |
||
247 | * Return any comma separated values in a request query field as an array. |
||
248 | * |
||
249 | * @param Request $request |
||
250 | * @param string $key |
||
251 | * @param string|null $validate Regular expression to test for each item |
||
252 | * |
||
253 | * @throws \Illuminate\Validation\ValidationException |
||
254 | * |
||
255 | * @return array |
||
256 | */ |
||
257 | protected function getRequestQuerySet($request, $key, $validate = null) |
||
274 | |||
275 | /** |
||
276 | * Validate the requested included relationships against those that are |
||
277 | * allowed on the requested resource type. |
||
278 | * |
||
279 | * @param array $relations |
||
280 | * |
||
281 | * @throws InvalidRelationPathException |
||
282 | */ |
||
283 | protected function validateIncludableRelations(array $relations) |
||
291 | |||
292 | /** |
||
293 | * Return the page number and page size to use for paginated results. |
||
294 | * |
||
295 | * @param \Illuminate\Http\Request $request |
||
296 | */ |
||
297 | protected function resolvePaginationParameters($request): array |
||
304 | } |
||
305 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: