diff --git a/src/Commands/ModuleMake.php b/src/Commands/ModuleMake.php index 7113d6230..7498b7a9c 100644 --- a/src/Commands/ModuleMake.php +++ b/src/Commands/ModuleMake.php @@ -756,7 +756,7 @@ public function createCapsuleRoutes(): void $contents = str_replace( '{{moduleName}}', - $this->capsule->getModule(), + $this->isSingleton ? lcfirst($this->capsule->getSingular()) : $this->capsule->getModule(), $this->files->get(__DIR__ . '/stubs/' . $stubFile) ); @@ -829,14 +829,14 @@ private function createCapsuleSingletonSeeder(): void { $repositoryName = $this->capsule->getSingular() . 'Repository'; $seederName = $this->capsule->getSingular() . 'Seeder'; - $dir = $this->databasePath('seeders'); + $dir = $this->capsule->getSeedsPsr4Path(); $this->makeTwillDirectory($dir); $stub = $this->files->get(__DIR__ . '/stubs/database_seeder_singleton.stub'); $stub = $this->replaceVariables([ - 'seederNamespace' => $this->capsule->getDatabaseNamespace() . '\\Seeders', + 'seederNamespace' => $this->capsule->getDatabaseNamespace() . '\\Seeds', 'seederClassName' => $seederName, 'modelClass' => $this->capsule->getModelNamespace() . "\\$modelName", 'modelClassName' => $modelName, diff --git a/src/Helpers/Capsule.php b/src/Helpers/Capsule.php index 491064f93..42c09bbbf 100644 --- a/src/Helpers/Capsule.php +++ b/src/Helpers/Capsule.php @@ -330,9 +330,9 @@ public function registerConfig(): void { $config = Config::get('twill-navigation', []); - $config[$this->name] = [ + $config[lcfirst($this->getSingular())] = [ 'title' => $this->name, - 'module' => true, + 'singleton' => true, ]; Config::set('twill-navigation', $config); diff --git a/src/Http/Controllers/Admin/SingletonModuleController.php b/src/Http/Controllers/Admin/SingletonModuleController.php index 39b854e57..bfc10b58b 100644 --- a/src/Http/Controllers/Admin/SingletonModuleController.php +++ b/src/Http/Controllers/Admin/SingletonModuleController.php @@ -2,6 +2,7 @@ namespace A17\Twill\Http\Controllers\Admin; +use A17\Twill\Facades\TwillCapsules; use Illuminate\Support\Facades\Session; abstract class SingletonModuleController extends ModuleController @@ -17,6 +18,10 @@ public function editSingleton() { $model = "App\\Models\\{$this->getModelName()}"; + if (!class_exists($model)) { + $model = TwillCapsules::getCapsuleForModel($this->modelName)->getModel(); + } + $item = app($model)->first(); if (!$item) { @@ -25,6 +30,6 @@ public function editSingleton() Session::put('pages_back_link', url()->current()); - return view("admin.{$this->moduleName}.form", $this->form($item->id)); + return view($this->viewPrefix . ".form", $this->form($item->id)); } }