1 | <?php |
||
25 | abstract class JsonApiController extends Controller |
||
26 | { |
||
27 | use JsonApiErrors; |
||
28 | use QueriesResources; |
||
29 | use UpdatesModelRelations; |
||
30 | use AuthorizesRequests; |
||
31 | use ValidatesRequests; |
||
32 | |||
33 | /** |
||
34 | * The Eloquent Model for the resource. |
||
35 | * |
||
36 | * @var Model|string |
||
37 | */ |
||
38 | protected $model; |
||
39 | |||
40 | /** |
||
41 | * Create a new JsonApiController instance. |
||
42 | */ |
||
43 | public function __construct() |
||
54 | |||
55 | /** |
||
56 | * Return a listing of the resource. |
||
57 | * |
||
58 | * @param Request $request |
||
59 | * @param \Illuminate\Database\Eloquent\Builder|null $query Custom resource query |
||
60 | * |
||
61 | * @return JsonApiResponse |
||
62 | */ |
||
63 | public function indexAction(Request $request, $query = null) |
||
83 | |||
84 | /** |
||
85 | * Store a new record. |
||
86 | * |
||
87 | * @param Request $request |
||
88 | * |
||
89 | * @return JsonApiResponse |
||
90 | */ |
||
91 | public function storeAction(Request $request) |
||
101 | |||
102 | /** |
||
103 | * Return a specified record. |
||
104 | * |
||
105 | * @param Request $request |
||
106 | * @param Model|mixed $record |
||
107 | * |
||
108 | * @return JsonApiResponse |
||
109 | */ |
||
110 | public function showAction(Request $request, $record) |
||
118 | |||
119 | /** |
||
120 | * Update a specified record. |
||
121 | * |
||
122 | * @param Request $request |
||
123 | * @param Model|mixed $record |
||
124 | * |
||
125 | * @return JsonApiResponse |
||
126 | */ |
||
127 | public function updateAction(Request $request, $record) |
||
139 | |||
140 | /** |
||
141 | * Destroy a specified record. |
||
142 | * |
||
143 | * @param Request $request |
||
144 | * @param Model|mixed $record |
||
145 | * |
||
146 | * @return JsonApiResponse |
||
147 | */ |
||
148 | public function destroyAction(Request $request, $record) |
||
155 | |||
156 | /** |
||
157 | * Return a specified record relationship. |
||
158 | * |
||
159 | * @param Request $request |
||
160 | * @param Model|mixed $record |
||
161 | * @param string $relation |
||
162 | * |
||
163 | * @return JsonApiResponse |
||
164 | */ |
||
165 | public function showRelationshipAction(Request $request, $record, $relation) |
||
171 | |||
172 | /** |
||
173 | * Update a named relationship on a specified record. |
||
174 | * |
||
175 | * http://jsonapi.org/format/#crud-updating-relationships |
||
176 | * |
||
177 | * @param Request $request |
||
178 | * @param Model|mixed $record |
||
179 | * @param string $relation |
||
180 | * |
||
181 | * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException |
||
182 | * |
||
183 | * @return JsonApiResponse |
||
184 | */ |
||
185 | 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) |
||
239 | |||
240 | /** |
||
241 | * Return any comma separated values in a request query field as an array. |
||
242 | * |
||
243 | * @param Request $request |
||
244 | * @param string $key |
||
245 | * @param string|null $validate Regular expression to test for each item |
||
246 | * |
||
247 | * @throws \Illuminate\Validation\ValidationException |
||
248 | * |
||
249 | * @return array |
||
250 | */ |
||
251 | protected function getRequestQuerySet($request, $key, $validate = null) |
||
268 | |||
269 | /** |
||
270 | * Validate the requested included relationships against those that are |
||
271 | * allowed on the requested resource type. |
||
272 | * |
||
273 | * @param array|null $relations |
||
274 | * |
||
275 | * @throws InvalidRelationPathException |
||
276 | */ |
||
277 | protected function validateIncludableRelations($relations) |
||
289 | } |
||
290 |
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: