Skip to content

Commit 0a177cf

Browse files
committed
fix
1 parent 6157615 commit 0a177cf

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/Fields/Relation.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,13 @@ public function saved(Request $request, Model $model): void
768768
*/
769769
public function resolveRouteBinding(Request $request, string $id): Model
770770
{
771-
return $this->getRelation($request->route()->parentOfParameter($this->getRouteKeyName()))->findOrFail($id);
771+
$parent = $request->route()->parentOfParameter($this->getRouteKeyName());
772+
773+
$model = $this->getRelation($parent)->findOrFail($id);
774+
775+
$parent->setRelation('_child', $model);
776+
777+
return $model;
772778
}
773779

774780
/**

src/Http/Controllers/MorphToController.php

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

21-
$data = $field->toInput($request, $related);
21+
$data = $field->toInput($request, $model->relationLoaded('_child') ? $model->getRelationValue('_child') : $model);
2222

2323
return ResponseFactory::view($data['template'], $data);
2424
}

src/Root.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Root
2727
*
2828
* @var string
2929
*/
30-
public const string VERSION = '2.7.7';
30+
public const string VERSION = '2.7.8';
3131

3232
/**
3333
* The registered booting callbacks.

0 commit comments

Comments
 (0)