Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Jun 27, 2024
1 parent 54cfe90 commit ff26f67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/Fields/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ public function fields(Request $request): array
);
});
})->hydrate(function (Request $request, Pivot $model, mixed $value): void {
$relation = $this->getRelation($model->pivotParent);

$model->setAttribute($relation->getRelatedPivotKeyName(), $value);
$model->setAttribute(
$this->getRelation($model->pivotParent)->getRelatedPivotKeyName(),
$value
);
})->display(function (Model $model): ?string {
return $this->resolveDisplay($model);
}),
Expand Down
8 changes: 3 additions & 5 deletions src/Fields/MorphToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ public function fields(Request $request): array
$this->getRelation($model->pivotParent)->select($query->getModel()->getQualifiedKeyName())
);
});
})->hydrate(function (Request $request, MorphPivot $model): void {
$relation = $this->getRelation($model->pivotParent);

})->hydrate(function (Request $request, MorphPivot $model, mixed $value): void {
$model->setAttribute(
$relation->getRelatedPivotKeyName(),
$model->related->getAttribute($relation->getRelatedKeyName())
$this->getRelation($model->pivotParent)->getRelatedPivotKeyName(),
$value
);
})->display(function (Model $model): mixed {
return $this->resolveDisplay($model);
Expand Down

0 comments on commit ff26f67

Please sign in to comment.