@@ -263,10 +263,8 @@ public function getRelated(
263
263
string $ relatedIdentifier
264
264
): JsonResponse {
265
265
try {
266
- return $ this ->getRelatedController (
267
- $ this ->getRelatedFromRelation ($ identifier , $ relation , $ relatedIdentifier ),
268
- $ relation
269
- )->get ($ relatedIdentifier , $ request );
266
+ return $ this ->getRelatedController ($ identifier , $ relation , $ relatedIdentifier )
267
+ ->get ($ relatedIdentifier , $ request );
270
268
} catch (\Throwable $ e ) {
271
269
if (!$ e instanceof ModelNotFoundException) {
272
270
Log::error ($ this ->label . '/ ' . $ identifier . '/ ' . $ relation . '/ ' . $ relatedIdentifier .
@@ -287,10 +285,8 @@ public function updateRelated(
287
285
string $ relatedIdentifier
288
286
): JsonResponse {
289
287
try {
290
- return $ this ->getRelatedController (
291
- $ this ->getRelatedFromRelation ($ identifier , $ relation , $ relatedIdentifier ),
292
- $ relation
293
- )->update ($ relatedIdentifier , $ request );
288
+ return $ this ->getRelatedController ($ identifier , $ relation , $ relatedIdentifier )
289
+ ->update ($ relatedIdentifier , $ request );
294
290
} catch (\Throwable $ e ) {
295
291
if (!$ e instanceof ModelNotFoundException) {
296
292
Log::error ($ this ->label . '/ ' . $ identifier . '/ ' . $ relation . '/ ' . $ relatedIdentifier .
@@ -307,10 +303,8 @@ public function updateRelated(
307
303
public function deleteRelated (string $ identifier , string $ relation , string $ relatedIdentifier ): JsonResponse
308
304
{
309
305
try {
310
- return $ this ->getRelatedController (
311
- $ this ->getRelatedFromRelation ($ identifier , $ relation , $ relatedIdentifier ),
312
- $ relation
313
- )->delete ($ relatedIdentifier );
306
+ return $ this ->getRelatedController ($ identifier , $ relation , $ relatedIdentifier )
307
+ ->delete ($ relatedIdentifier );
314
308
} catch (\Throwable $ e ) {
315
309
if (!$ e instanceof ModelNotFoundException) {
316
310
Log::error ($ this ->label . '/ ' . $ identifier . '/ ' . $ relation . '/ ' . $ relatedIdentifier .
@@ -467,8 +461,12 @@ protected function throwIfForbidden(bool $condition): void
467
461
* @return self
468
462
* @throws \Throwable
469
463
*/
470
- protected function getRelatedController (BaseModel $ related , string $ relation ): object
471
- {
464
+ protected function getRelatedController (
465
+ string $ identifier ,
466
+ string $ relation ,
467
+ string $ relatedIdentifier
468
+ ): object {
469
+ $ related = $ this ->getRelatedFromRelation ($ identifier , $ relation , $ relatedIdentifier );
472
470
$ controllerFqn = (string )($ this ->modelFqnToControllerMap [$ related ::class] ??
473
471
($ this ->relatedModelFqnToControllerMap [$ related ::class] ?? '' ));
474
472
@@ -497,12 +495,12 @@ protected function getRelatedFromRelation(
497
495
498
496
foreach ($ related ->getPrimaryKeyFilter () as $ column => $ value ) {
499
497
if (!\is_array ($ value ) && \is_string ($ column )) {
500
- $ pks [] = $ column ;
498
+ $ pks [] = $ related -> qualifyColumn ( $ column) ;
501
499
502
500
continue ;
503
501
}
504
502
505
- $ pks [] = \reset ($ value );
503
+ $ pks [] = $ related -> qualifyColumn ( \reset ($ value) );
506
504
}
507
505
508
506
if (
0 commit comments