diff --git a/composer.json b/composer.json
index c46ebf8d0..1fd200dbe 100644
--- a/composer.json
+++ b/composer.json
@@ -19,6 +19,7 @@
"lavary/laravel-menu": "^1.8",
"livewire/livewire": "^2.10",
"mews/purifier": "^3.3",
+ "nasirkhan/module-manager": "^0.3.0",
"nwidart/laravel-modules": "^9.0",
"predis/predis": "^1.1",
"spatie/laravel-activitylog": "^4.5",
diff --git a/composer.lock b/composer.lock
index f32947e89..a8792557e 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "7f9e087391ddbb7b6ac80d7be6497372",
+ "content-hash": "591a8c01417a50356714715c8e67aea7",
"packages": [
{
"name": "alexusmai/laravel-file-manager",
@@ -2183,16 +2183,16 @@
},
{
"name": "league/flysystem",
- "version": "3.10.2",
+ "version": "3.10.3",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
- "reference": "b9bd194b016114d6ff6765c09d40c7d427e4e3f6"
+ "reference": "8013fb046c6a244b2b1b75cc95d732ed6bcdeb8a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/b9bd194b016114d6ff6765c09d40c7d427e4e3f6",
- "reference": "b9bd194b016114d6ff6765c09d40c7d427e4e3f6",
+ "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8013fb046c6a244b2b1b75cc95d732ed6bcdeb8a",
+ "reference": "8013fb046c6a244b2b1b75cc95d732ed6bcdeb8a",
"shasum": ""
},
"require": {
@@ -2254,7 +2254,7 @@
],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
- "source": "https://github.com/thephpleague/flysystem/tree/3.10.2"
+ "source": "https://github.com/thephpleague/flysystem/tree/3.10.3"
},
"funding": [
{
@@ -2270,7 +2270,7 @@
"type": "tidelift"
}
],
- "time": "2022-10-25T07:01:47+00:00"
+ "time": "2022-11-14T10:42:43+00:00"
},
{
"name": "league/glide",
@@ -2861,6 +2861,64 @@
],
"time": "2022-08-04T09:53:51+00:00"
},
+ {
+ "name": "nasirkhan/module-manager",
+ "version": "v0.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nasirkhan/module-manager.git",
+ "reference": "5bf437f7be9610f2a59f46eea9e0eb8b7752531e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nasirkhan/module-manager/zipball/5bf437f7be9610f2a59f46eea9e0eb8b7752531e",
+ "reference": "5bf437f7be9610f2a59f46eea9e0eb8b7752531e",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^8.0"
+ },
+ "type": "library",
+ "extra": {
+ "laravel": {
+ "providers": [
+ "Nasirkhan\\ModuleManager\\ModuleManagerServiceProvider"
+ ],
+ "aliases": {
+ "ModuleManager": "Nasirkhan\\ModuleManager\\ModuleManagerFacade"
+ }
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Nasirkhan\\ModuleManager\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nasir Khan",
+ "email": "nasir8891@gmail.com",
+ "role": "Developer"
+ }
+ ],
+ "description": "Module Manager & Generator for Laravel Starter Kit (https://github.com/nasirkhan/laravel-starter)",
+ "homepage": "https://github.com/nasirkhan/module-manager",
+ "keywords": [
+ "laravel-starter",
+ "module-generator",
+ "module-manager",
+ "nasirkhan"
+ ],
+ "support": {
+ "issues": "https://github.com/nasirkhan/module-manager/issues",
+ "source": "https://github.com/nasirkhan/module-manager/tree/v0.3.0"
+ },
+ "time": "2022-11-15T04:13:45+00:00"
+ },
{
"name": "nesbot/carbon",
"version": "2.63.0",
@@ -4381,21 +4439,21 @@
},
{
"name": "spatie/laravel-activitylog",
- "version": "4.7.1",
+ "version": "4.7.2",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-activitylog.git",
- "reference": "3619d823069333018dd94aa36ef900b88497210d"
+ "reference": "eee61436e2984119fd71fc338a45ec7d68e3b548"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/spatie/laravel-activitylog/zipball/3619d823069333018dd94aa36ef900b88497210d",
- "reference": "3619d823069333018dd94aa36ef900b88497210d",
+ "url": "https://api.github.com/repos/spatie/laravel-activitylog/zipball/eee61436e2984119fd71fc338a45ec7d68e3b548",
+ "reference": "eee61436e2984119fd71fc338a45ec7d68e3b548",
"shasum": ""
},
"require": {
"illuminate/config": "^8.0 || ^9.0",
- "illuminate/database": "^8.53 || ^9.0",
+ "illuminate/database": "^8.69 || ^9.27",
"illuminate/support": "^8.0 || ^9.0",
"php": "^8.0",
"spatie/laravel-package-tools": "^1.6.3"
@@ -4456,7 +4514,7 @@
],
"support": {
"issues": "https://github.com/spatie/laravel-activitylog/issues",
- "source": "https://github.com/spatie/laravel-activitylog/tree/4.7.1"
+ "source": "https://github.com/spatie/laravel-activitylog/tree/4.7.2"
},
"funding": [
{
@@ -4468,7 +4526,7 @@
"type": "github"
}
],
- "time": "2022-11-11T15:38:25+00:00"
+ "time": "2022-11-14T12:16:46+00:00"
},
{
"name": "spatie/laravel-backup",
diff --git a/config/module-manager.php b/config/module-manager.php
new file mode 100644
index 000000000..af594da32
--- /dev/null
+++ b/config/module-manager.php
@@ -0,0 +1,64 @@
+ 'Modules',
+
+ 'stubs' => [
+ 'path' => base_path('stubs/laravel-starter-stubs'),
+ ],
+
+ 'module' => [
+ 'files' => [
+ 'composer' => ['composer.stub', 'composer.json'],
+ 'json' => ['module.stub', 'module.json'],
+ 'config' => ['Config/config.stub', 'Config/config.php'],
+ 'database' => ['database/migrations/stubMigration.stub', 'database/migrations/stubMigration.php', 'rename'],
+ 'factories' => ['database/factories/stubFactory.stub', 'database/factories/stubFactory.php', 'rename'],
+ 'seeders' => ['database/seeders/stubSeeders.stub', 'database/seeders/stubSeeders.php', 'rename'],
+ 'command' => ['Console/Commands/StubCommand.stub', 'Console/Commands/StubCommand.php', 'rename'],
+ 'lang' => ['lang/en/text.stub', 'lang/en/text.php'],
+ 'models' => ['Models/stubModel.stub', 'Models/stubModel.php'],
+ 'providersRoute' => ['Providers/RouteServiceProvider.stub', 'Providers/RouteServiceProvider.php'],
+ 'providers' => ['Providers/stubServiceProvider.stub', 'Providers/stubServiceProvider.php'],
+ 'route_web' => ['routes/web.stub', 'routes/web.php'],
+ 'route_api' => ['routes/api.stub', 'routes/api.php'],
+ 'controller_backend' => ['Http/Controllers/Backend/stubBackendController.stub', 'Http/Controllers/Backend/stubBackendController.php'],
+ 'controller_frontend' => ['Http/Controllers/Frontend/stubFrontendController.stub', 'Http/Controllers/Frontend/stubFrontendController.php'],
+ 'middleware_menu' => ['Http/Middleware/GenerateMenus.stub', 'Http/Middleware/GenerateMenus.php'],
+ 'views_backend_index' => ['Resources/views/backend/stubViews/index.blade.stub', 'Resources/views/backend/stubViews/index.blade.php'],
+ 'views_backend_index_datatable' => ['Resources/views/backend/stubViews/index_datatable.blade.stub', 'Resources/views/backend/stubViews/index_datatable.blade.php'],
+ 'views_backend_create' => ['Resources/views/backend/stubViews/create.blade.stub', 'Resources/views/backend/stubViews/create.blade.php'],
+ 'views_backend_form' => ['Resources/views/backend/stubViews/form.blade.stub', 'Resources/views/backend/stubViews/form.blade.php'],
+ 'views_backend_show' => ['Resources/views/backend/stubViews/show.blade.stub', 'Resources/views/backend/stubViews/show.blade.php'],
+ 'views_backend_edit' => ['Resources/views/backend/stubViews/edit.blade.stub', 'Resources/views/backend/stubViews/edit.blade.php'],
+ 'views_backend_trash' => ['Resources/views/backend/stubViews/trash.blade.stub', 'Resources/views/backend/stubViews/trash.blade.php'],
+ 'views_frontend_index' => ['Resources/views/frontend/stubViews/index.blade.stub', 'Resources/views/frontend/stubViews/index.blade.php'],
+ 'views_frontend_show' => ['Resources/views/frontend/stubViews/show.blade.stub', 'Resources/views/frontend/stubViews/show.blade.php'],
+ ],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Module Composer
+ |--------------------------------------------------------------------------
+ |
+ | Config for the composer.json file
+ |
+ */
+
+ 'composer' => [
+ 'vendor' => 'nasirkhan',
+ 'author' => [
+ 'name' => 'Nasir Khan',
+ 'email' => 'nasir8891@gmail.com',
+ ],
+ ],
+];
diff --git a/stubs/module-stubs/assets/js/app.stub b/stubs/laravel-starter-stubs/Config/.gitkeep
similarity index 100%
rename from stubs/module-stubs/assets/js/app.stub
rename to stubs/laravel-starter-stubs/Config/.gitkeep
diff --git a/stubs/laravel-starter-stubs/Config/config.stub b/stubs/laravel-starter-stubs/Config/config.stub
new file mode 100644
index 000000000..ea9df15a5
--- /dev/null
+++ b/stubs/laravel-starter-stubs/Config/config.stub
@@ -0,0 +1,5 @@
+ '{{moduleName}}',
+];
diff --git a/stubs/module-stubs/assets/sass/app.stub b/stubs/laravel-starter-stubs/Console/.gitkeep
similarity index 100%
rename from stubs/module-stubs/assets/sass/app.stub
rename to stubs/laravel-starter-stubs/Console/.gitkeep
diff --git a/stubs/laravel-starter-stubs/Console/Commands/StubCommand.stub b/stubs/laravel-starter-stubs/Console/Commands/StubCommand.stub
new file mode 100644
index 000000000..2d6a16dce
--- /dev/null
+++ b/stubs/laravel-starter-stubs/Console/Commands/StubCommand.stub
@@ -0,0 +1,32 @@
+module_title = '{{moduleNamePlural}}';
+
+ // module name
+ $this->module_name = '{{moduleNameLowerPlural}}';
+
+ // directory path of the module
+ $this->module_path = '{{moduleNameLower}}::backend';
+
+ // module icon
+ $this->module_icon = 'fa-regular fa-sun';
+
+ // module model name, path
+ $this->module_model = "{{namespace}}\{{moduleName}}\Models\{{moduleName}}";
+ }
+
+}
diff --git a/stubs/laravel-starter-stubs/Http/Controllers/Frontend/stubFrontendController.stub b/stubs/laravel-starter-stubs/Http/Controllers/Frontend/stubFrontendController.stub
new file mode 100644
index 000000000..20d31df21
--- /dev/null
+++ b/stubs/laravel-starter-stubs/Http/Controllers/Frontend/stubFrontendController.stub
@@ -0,0 +1,79 @@
+module_title = '{{moduleNamePlural}}';
+
+ // module name
+ $this->module_name = '{{moduleNameLowerPlural}}';
+
+ // directory path of the module
+ $this->module_path = '{{moduleNameLower}}::backend';
+
+ // module icon
+ $this->module_icon = 'fa-regular fa-sun';
+
+ // module model name, path
+ $this->module_model = "{{namespace}}\{{moduleName}}\Models\{{moduleName}}";
+ }
+
+ /**
+ * Display a listing of the resource.
+ *
+ * @return Response
+ */
+ public function index()
+ {
+ $module_title = $this->module_title;
+ $module_name = $this->module_name;
+ $module_path = $this->module_path;
+ $module_icon = $this->module_icon;
+ $module_model = $this->module_model;
+ $module_name_singular = Str::singular($module_name);
+
+ $module_action = 'List';
+
+ $$module_name = $module_model::latest()->paginate();
+
+ return view(
+ "{{moduleNameLower}}::frontend.$module_path.index",
+ compact('module_title', 'module_name', "$module_name", 'module_icon', 'module_action', 'module_name_singular')
+ );
+ }
+
+ /**
+ * Display the specified resource.
+ *
+ * @param int $id
+ * @return Response
+ */
+ public function show($id)
+ {
+ $id = decode_id($id);
+
+ $module_title = $this->module_title;
+ $module_name = $this->module_name;
+ $module_path = $this->module_path;
+ $module_icon = $this->module_icon;
+ $module_model = $this->module_model;
+ $module_name_singular = Str::singular($module_name);
+
+ $module_action = 'Show';
+
+ $$module_name_singular = $module_model::findOrFail($id);
+
+ return view(
+ "{{moduleNameLower}}::frontend.$module_name.show",
+ compact('module_title', 'module_name', 'module_icon', 'module_action', 'module_name_singular', "$module_name_singular", 'posts')
+ );
+ }
+}
diff --git a/stubs/laravel-starter-stubs/Http/Middleware/.gitkeep b/stubs/laravel-starter-stubs/Http/Middleware/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/stubs/laravel-starter-stubs/Http/Middleware/GenerateMenus.stub b/stubs/laravel-starter-stubs/Http/Middleware/GenerateMenus.stub
new file mode 100644
index 000000000..f9ac04924
--- /dev/null
+++ b/stubs/laravel-starter-stubs/Http/Middleware/GenerateMenus.stub
@@ -0,0 +1,43 @@
+add(' '.__('{{moduleNamePlural}}'), [
+ 'route' => 'backend.{{moduleNameLowerPlural}}.index',
+ 'class' => 'nav-item',
+ ])
+ ->data([
+ 'order' => 77,
+ 'activematches' => ['admin/{{moduleNameLowerPlural}}*'],
+ 'permission' => ['view_{{moduleNameLowerPlural}}'],
+ ])
+ ->link->attr([
+ 'class' => 'nav-link',
+ ]);
+ })->sortBy('order');
+
+ return $next($request);
+ }
+}
diff --git a/stubs/laravel-starter-stubs/Models/stubModel.stub b/stubs/laravel-starter-stubs/Models/stubModel.stub
new file mode 100644
index 000000000..470f4c0eb
--- /dev/null
+++ b/stubs/laravel-starter-stubs/Models/stubModel.stub
@@ -0,0 +1,25 @@
+namespace($this->moduleNamespace)
- ->group(module_path('$MODULE$', '$WEB_ROUTES_PATH$'));
+ ->group(base_path('{{namespace}}/{{moduleName}}/routes/web.php'));
}
/**
@@ -63,7 +55,6 @@ class $CLASS$ extends ServiceProvider
{
Route::prefix('api')
->middleware('api')
- ->namespace($this->moduleNamespace)
- ->group(module_path('$MODULE$', '$API_ROUTES_PATH$'));
+ ->group(base_path('{{namespace}}/{{moduleName}}/routes/api.php'));
}
}
diff --git a/stubs/module-stubs/scaffold/provider.stub b/stubs/laravel-starter-stubs/Providers/stubServiceProvider.stub
similarity index 59%
rename from stubs/module-stubs/scaffold/provider.stub
rename to stubs/laravel-starter-stubs/Providers/stubServiceProvider.stub
index eab84ebfa..b8ca84932 100644
--- a/stubs/module-stubs/scaffold/provider.stub
+++ b/stubs/laravel-starter-stubs/Providers/stubServiceProvider.stub
@@ -1,23 +1,22 @@
registerTranslations();
$this->registerConfig();
$this->registerViews();
- $this->loadMigrationsFrom(module_path($this->moduleName, '$MIGRATIONS_PATH$'));
+ $this->loadMigrationsFrom(base_path('{{namespace}}/{{moduleName}}/database/migrations'));
// adding global middleware
$kernel = $this->app->make('Illuminate\Contracts\Http\Kernel');
- $kernel->pushMiddleware('Modules\Tag\Http\Middleware\GenerateMenus');
+ $kernel->pushMiddleware('{{namespace}}\{{moduleName}}\Http\Middleware\GenerateMenus');
// register commands
- $this->registerCommands('\Modules\Tag\Console');
+ $this->registerCommands('\{{namespace}}\{{moduleName}}\Console\Commands');
}
/**
@@ -57,10 +56,10 @@ class $CLASS$ extends ServiceProvider
protected function registerConfig()
{
$this->publishes([
- module_path($this->moduleName, '$PATH_CONFIG$/config.php') => config_path($this->moduleNameLower . '.php'),
+ base_path('{{namespace}}/{{moduleName}}/Config/config.php') => config_path($this->moduleNameLower.'.php'),
], 'config');
$this->mergeConfigFrom(
- module_path($this->moduleName, '$PATH_CONFIG$/config.php'), $this->moduleNameLower
+ base_path('{{namespace}}/{{moduleName}}/Config/config.php'), $this->moduleNameLower
);
}
@@ -71,13 +70,13 @@ class $CLASS$ extends ServiceProvider
*/
public function registerViews()
{
- $viewPath = resource_path('views/modules/' . $this->moduleNameLower);
+ $viewPath = resource_path('views/modules/'.$this->moduleNameLower);
- $sourcePath = module_path($this->moduleName, '$PATH_VIEWS$');
+ $sourcePath = base_path('{{namespace}}/{{moduleName}}/Resources/views');
$this->publishes([
- $sourcePath => $viewPath
- ], ['views', $this->moduleNameLower . '-module-views']);
+ $sourcePath => $viewPath,
+ ], ['views', $this->moduleNameLower.'-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
}
@@ -89,13 +88,7 @@ class $CLASS$ extends ServiceProvider
*/
public function registerTranslations()
{
- $langPath = resource_path('lang/modules/' . $this->moduleNameLower);
-
- if (is_dir($langPath)) {
- $this->loadTranslationsFrom($langPath, $this->moduleNameLower);
- } else {
- $this->loadTranslationsFrom(module_path($this->moduleName, '$PATH_LANG$'), $this->moduleNameLower);
- }
+ $this->loadTranslationsFrom(__DIR__ . '/../lang', '{{moduleNameLower}}');
}
/**
@@ -112,17 +105,18 @@ class $CLASS$ extends ServiceProvider
{
$paths = [];
foreach (Config::get('view.paths') as $path) {
- if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
- $paths[] = $path . '/modules/' . $this->moduleNameLower;
+ if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
+ $paths[] = $path.'/modules/'.$this->moduleNameLower;
}
}
+
return $paths;
}
/**
* Register commands.
*
- * @param string $namespace
+ * @param string $namespace
*/
protected function registerCommands($namespace = '')
{
diff --git a/stubs/laravel-starter-stubs/Resources/assets/.gitkeep b/stubs/laravel-starter-stubs/Resources/assets/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/stubs/laravel-starter-stubs/Resources/assets/js/app.js b/stubs/laravel-starter-stubs/Resources/assets/js/app.js
new file mode 100644
index 000000000..e69de29bb
diff --git a/stubs/laravel-starter-stubs/Resources/assets/sass/app.scss b/stubs/laravel-starter-stubs/Resources/assets/sass/app.scss
new file mode 100644
index 000000000..e69de29bb
diff --git a/stubs/laravel-starter-stubs/Resources/views/.gitkeep b/stubs/laravel-starter-stubs/Resources/views/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/create.blade.stub b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/create.blade.stub
new file mode 100644
index 000000000..73ed77fae
--- /dev/null
+++ b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/create.blade.stub
@@ -0,0 +1,69 @@
+@extends('backend.layouts.app')
+
+@section('title') {{ __($module_action) }} {{ __($module_title) }} @endsection
+
+@section('breadcrumbs')
+
+ # + | ++ @lang("{{moduleNameLower}}::text.name") + | ++ @lang("{{moduleNameLower}}::text.slug") + | ++ @lang("{{moduleNameLower}}::text.updated_at") + | ++ @lang("{{moduleNameLower}}::text.created_by") + | ++ @lang("{{moduleNameLower}}::text.action") + | +
---|---|---|---|---|---|
+ {{ $module_name_singular->id }} + | ++ id) }}">{{ $module_name_singular->name }} + | ++ {{ $module_name_singular->slug }} + | ++ {{ $module_name_singular->updated_at->diffForHumans() }} + | ++ {{ $module_name_singular->created_by }} + | ++ + + | +
+ # + | ++ @lang("{{moduleNameLower}}::text.name") + | ++ @lang("{{moduleNameLower}}::text.updated_at") + | ++ @lang("{{moduleNameLower}}::text.action") + | +
---|
+ # + | ++ Name + | ++ Updated At + | ++ Created By + | ++ Action + | +
---|---|---|---|---|
+ {{ $module_name_singular->id }} + | ++ + {{ $module_name_singular->name }} + + | ++ {{ $module_name_singular->updated_at->isoFormat('llll') }} + | ++ {{ $module_name_singular->created_by }} + | ++ {{__('labels.backend.restore')}} + | +
+ The list of tags. +
+ + @include('frontend.includes.messages') ++ {{$$module_name_singular->description}} +
++ Total {{$$module_name_singular->posts->count()}} posts. +
+ ++ {{$$module_name_singular->description}} +
+ + @include('frontend.includes.messages') +- This view is loaded from module: {!! config('$LOWER_NAME$.name') !!} -
-@endsection diff --git a/stubs/module-stubs/views/master.stub b/stubs/module-stubs/views/master.stub deleted file mode 100644 index bb09abbb5..000000000 --- a/stubs/module-stubs/views/master.stub +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - -