Skip to content

Commit 61cc52c

Browse files
committed
wip
1 parent 0a177cf commit 61cc52c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Fields/Relation.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -770,11 +770,7 @@ public function resolveRouteBinding(Request $request, string $id): Model
770770
{
771771
$parent = $request->route()->parentOfParameter($this->getRouteKeyName());
772772

773-
$model = $this->getRelation($parent)->findOrFail($id);
774-
775-
$parent->setRelation('_child', $model);
776-
777-
return $model;
773+
return $this->getRelation($parent)->findOrFail($id);
778774
}
779775

780776
/**

src/Http/Controllers/MorphToController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ class MorphToController extends Controller
1414
/**
1515
* Handle the incoming request.
1616
*/
17-
public function __invoke(Request $request, Model $model): Response
17+
public function __invoke(Request $request, Model $model, ...$params): Response
1818
{
1919
$field = $request->route('field');
2020

21-
$data = $field->toInput($request, $model->relationLoaded('_child') ? $model->getRelationValue('_child') : $model);
21+
$related = array_filter($params, fn (mixed $param): bool => $param instanceof Model);
22+
23+
$related = $related[array_key_last($related)] ?? null;
24+
25+
$data = $field->toInput($request, $related ?: $model);
2226

2327
return ResponseFactory::view($data['template'], $data);
2428
}

0 commit comments

Comments
 (0)