Skip to content

Commit

Permalink
Fix getModulePermalink base area17#2470
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofandel authored and AidasK committed May 4, 2024
1 parent 5a599b1 commit 9eee480
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Http/Controllers/Admin/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2418,17 +2418,18 @@ protected function getModulePermalinkBase(): string
foreach ($moduleParts as $index => $name) {
if (array_key_last($moduleParts) !== $index) {
$singularName = Str::singular($name);
$modelClass = config('twill.namespace') . '\\Models\\' . Str::studly($singularName);
$modelName = Str::studly($singularName);
$modelClass = config('twill.namespace') . '\\Models\\' . $modelName;

if (! @class_exists($modelClass)) {
// First try to construct it based on the last.
$modelClass = config('twill.namespace') .
'\\Models\\' .
implode('', array_merge($prev + [99 => Str::studly($singularName)]));
implode('', array_merge($prev, [$modelName]));

// Last option is to search for a capsule model.
if (! class_exists($modelClass)) {
$modelClass = TwillCapsules::getCapsuleForModel($name)->getModel();
$modelClass = TwillCapsules::getCapsuleForModel($modelName)->getModel();
}
}

Expand Down

0 comments on commit 9eee480

Please sign in to comment.