Skip to content

Commit

Permalink
Fix child module redirect when adding new records in Laravel 6 / 7
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceverheije authored and ifox committed Mar 12, 2020
1 parent f66aaa6 commit e60c506
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Http/Controllers/Admin/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,22 @@ public function store($parentModuleId = null)
return $this->respondWithSuccess('Content saved. All good!');
}

if ($parentModuleId) {
$params = [
Str::singular(explode('.', $this->moduleName)[0]) => $parentModuleId,
Str::singular(explode('.', $this->moduleName)[1]) => $item->id,
];
} else {
$params = [
Str::singular($this->moduleName) => $item->id,
];
}

return $this->respondWithRedirect(moduleRoute(
$this->moduleName,
$this->routePrefix,
'edit',
array_filter([$parentModuleId]) + [Str::singular($this->moduleName) => $item->id]
$params
));
}

Expand Down

0 comments on commit e60c506

Please sign in to comment.