From 75c2abd2b8ee19fbba0a956a3172ef162ddf0f0b Mon Sep 17 00:00:00 2001 From: Dominik Hendrix Date: Thu, 22 Aug 2024 13:50:10 +0200 Subject: [PATCH 1/2] generated modules.js use window.Crater which is undefined, use window.InvoiceShelf instead --- src/Commands/stubs/resources/scripts/module.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/stubs/resources/scripts/module.stub b/src/Commands/stubs/resources/scripts/module.stub index f396161..9e7055e 100644 --- a/src/Commands/stubs/resources/scripts/module.stub +++ b/src/Commands/stubs/resources/scripts/module.stub @@ -2,8 +2,8 @@ import SamplePage from './views/SamplePage.vue' import moduleLocales from '~/locales/locales' import '../sass/module.scss' -window.Crater.booting((app, router) => { - window.Crater.addMessages(moduleLocales) +window.InvoiceShelf.booting((app, router) => { + window.InvoiceShelf.addMessages(moduleLocales) router.addRoute({ path: '/$LOWER_NAME$/sample-page', From c6cdea30214a92fc381dfd5015731c3118c325b4 Mon Sep 17 00:00:00 2001 From: Dominik Hendrix Date: Thu, 22 Aug 2024 14:05:29 +0200 Subject: [PATCH 2/2] Update script and provider stubs for module creation --- config/config.php | 4 +-- .../stubs/resources/scripts/module.stub | 4 +-- src/Commands/stubs/scaffold/provider.stub | 31 +++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/config/config.php b/config/config.php index 18d96d1..c925d64 100644 --- a/config/config.php +++ b/config/config.php @@ -64,8 +64,8 @@ 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE', ], - 'assets/scripts/module' => ['LOWER_NAME'], - 'assets/scripts/stores/sample-store' => ['LOWER_NAME'], + 'resources/scripts/module' => ['LOWER_NAME'], + 'resources/scripts/stores/sample-store' => ['LOWER_NAME'], 'vite.config' => ['LOWER_NAME'], ], 'gitkeep' => true, diff --git a/src/Commands/stubs/resources/scripts/module.stub b/src/Commands/stubs/resources/scripts/module.stub index 9e7055e..355360c 100644 --- a/src/Commands/stubs/resources/scripts/module.stub +++ b/src/Commands/stubs/resources/scripts/module.stub @@ -5,8 +5,8 @@ import '../sass/module.scss' window.InvoiceShelf.booting((app, router) => { window.InvoiceShelf.addMessages(moduleLocales) - router.addRoute({ - path: '/$LOWER_NAME$/sample-page', + router.addRoute('admin', { + path: '$LOWER_NAME$', component: SamplePage, }) diff --git a/src/Commands/stubs/scaffold/provider.stub b/src/Commands/stubs/scaffold/provider.stub index 4a4f053..416ae9e 100644 --- a/src/Commands/stubs/scaffold/provider.stub +++ b/src/Commands/stubs/scaffold/provider.stub @@ -27,6 +27,8 @@ class $CLASS$ extends ServiceProvider $this->registerTranslations(); $this->registerConfig(); $this->registerViews(); + $this->registerMenu(); + $this->registerPublicFiles(); $this->loadMigrationsFrom(module_path($this->moduleName, '$MIGRATIONS_PATH$')); } @@ -109,4 +111,33 @@ class $CLASS$ extends ServiceProvider } return $paths; } + + public function registerMenu() + { + $data = [ + 'title' => '$LOWER_NAME$.$LOWER_NAME$_title', + 'name' => '$MODULE$', + 'link' => '/admin/$LOWER_NAME$', + 'icon' => 'QuestionMarkCircleIcon', + 'group' => 1, + ]; + + \Menu::make('main_menu', function ($menu) use ($data) { + $menu->add($data['title'], $data['link']) + ->data('icon', $data['icon']) + ->data('name', $data['name']) + ->data('group', $data['group']); + }); + } + + /** + * Register public files. + * + * @return void + */ + protected function registerPublicFiles() + { + ModuleFacade::script('$LOWER_NAME$', __DIR__ . '/../dist/$LOWER_NAME$.umd.js'); + ModuleFacade::style('$LOWER_NAME$', __DIR__ . '/../dist/style.css'); + } }