Skip to content

Commit

Permalink
model url fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Dec 29, 2023
1 parent afbf04d commit 4bff9cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Fields/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ public function mapRelated(Request $request, Model $model, Model $related): arra
*/
public function modelUrl(Model $model): string
{
return str_replace('{resourceModel}', $model->getKey(), $this->getUri());
return str_replace('{resourceModel}', $model->exists ? $model->getKey() : 'create', $this->getUri());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Fields/Repeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function withFields(Closure $callback): static
{
$this->optionFieldsResolver = function (Request $request, Model $model, Model $tmpModel) use ($callback): Fields {
$fields = new Fields([
Hidden::make(__('Key'), '_key'),
Hidden::make(__('Key'), '_key')
]);

$fields->register(call_user_func_array($callback, [$request, $model, $tmpModel]));
Expand Down Expand Up @@ -185,7 +185,7 @@ public function buildOption(Request $request, Model $model): array
*/
public function modelUrl(Model $model): string
{
return str_replace('{resourceModel}', $model->getKey(), $this->getUri());
return str_replace('{resourceModel}', $model->exists ? $model->getKey() : 'create', $this->getUri());
}

/**
Expand Down

0 comments on commit 4bff9cf

Please sign in to comment.