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') + + + {{ __($module_title) }} + + {{ __($module_action) }} + +@endsection + +@section('content') +
+
+ + + {{ __($module_title) }} {{ __($module_action) }} + + + @lang(":module_name Management Dashboard", ['module_name'=>Str::title($module_name)]) + + + + List + + + +
+ +
+
+ {{ html()->form('POST', route("backend.$module_name.store"))->acceptsFiles()->class('form')->open() }} + + @include ("$module_path.$module_name.form") + +
+
+
+ {{ html()->button($text = " " . ucfirst($module_action) . "", $type = 'submit')->class('btn btn-success') }} +
+
+
+
+
+ +
+
+
+
+ + {{ html()->form()->close() }} + +
+
+
+ + +
+ + +@endsection \ No newline at end of file diff --git a/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/edit.blade.stub b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/edit.blade.stub new file mode 100644 index 000000000..7786c493a --- /dev/null +++ b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/edit.blade.stub @@ -0,0 +1,71 @@ +@extends('backend.layouts.app') + +@section('title') {{ __($module_action) }} {{ __($module_title) }} @endsection + +@section('breadcrumbs') + + + {{ __($module_title) }} + + {{ __($module_action) }} + +@endsection + +@section('content') +
+
+ + {{ __($module_title) }} {{ __($module_action) }} + + + @lang(":module_name Management Dashboard", ['module_name'=>Str::title($module_name)]) + + + + + + + +
+ +
+
+ {{ html()->modelForm($$module_name_singular, 'PATCH', route("backend.$module_name.update", $$module_name_singular))->acceptsFiles()->class('form')->open() }} + + @include ("$module_path.$module_name.form") + +
+
+
+ {{ html()->submit($text = icon('fas fa-save')." Save")->class('btn btn-success') }} +
+
+ {{ html()->form()->close() }} + +
+
+ @can('delete_'.$module_name) + + @endcan + +
+
+
+ +
+
+
+ + +
+ +@endsection \ No newline at end of file diff --git a/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/form.blade.stub b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/form.blade.stub new file mode 100644 index 000000000..f7e5874b8 --- /dev/null +++ b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/form.blade.stub @@ -0,0 +1,59 @@ +
+
+
+ + {{ html()->label($field_lable, $field_name)->class('form-label') }} {!! fielf_required($required) !!} + {{ html()->text($field_name)->placeholder($field_placeholder)->class('form-control')->attributes(["$required"]) }} +
+
+
+
+ + {{ html()->label($field_lable, $field_name)->class('form-label') }} {!! fielf_required($required) !!} + {{ html()->text($field_name)->placeholder($field_placeholder)->class('form-control')->attributes(["$required"]) }} +
+
+
+
+ 'Published', + '0'=>'Unpublished', + '2'=>'Draft' + ]; + ?> + {{ html()->label($field_lable, $field_name)->class('form-label') }} {!! fielf_required($required) !!} + {{ html()->select($field_name, $select_options)->placeholder($field_placeholder)->class('form-control select2')->attributes(["$required"]) }} +
+
+
+ +
+
+
+ + {{ html()->label($field_lable, $field_name)->class('form-label') }} {!! fielf_required($required) !!} + {{ html()->textarea($field_name)->placeholder($field_placeholder)->class('form-control')->attributes(["$required"]) }} +
+
+
+ diff --git a/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/index.blade.stub b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/index.blade.stub new file mode 100644 index 000000000..53519ae9d --- /dev/null +++ b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/index.blade.stub @@ -0,0 +1,116 @@ +@extends('backend.layouts.app') + +@section('title') {{ __($module_action) }} {{ __($module_title) }} @endsection + +@section('breadcrumbs') + + {{ __($module_title) }} + +@endsection + +@section('content') +
+
+ + + {{ __($module_title) }} {{ __($module_action) }} + + + @lang(":module_name Management Dashboard", ['module_name'=>Str::title($module_name)]) + + + @can('add_'.$module_name) + + @endcan + + @can('restore_'.$module_name) +
+ + +
+ @endcan +
+
+ +
+
+ + + + + + + + + + + + + + @foreach($$module_name as $module_name_singular) + + + + + + + + + @endforeach + +
+ # + + @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 }} + + + +
+
+
+
+ +
+@endsection \ No newline at end of file diff --git a/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/index_datatable.blade.stub b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/index_datatable.blade.stub new file mode 100644 index 000000000..8d31aba80 --- /dev/null +++ b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/index_datatable.blade.stub @@ -0,0 +1,125 @@ +@extends('backend.layouts.app') + +@section('title') {{ __($module_action) }} {{ __($module_title) }} @endsection + +@section('breadcrumbs') + + {{ __($module_title) }} + +@endsection + +@section('content') +
+
+ + + {{ __($module_title) }} {{ __($module_action) }} + + + @lang(":module_name Management Dashboard", ['module_name'=>Str::title($module_name)]) + + + @can('add_'.$module_name) + + @endcan + + @can('restore_'.$module_name) +
+ + +
+ @endcan +
+
+ +
+
+ + + + + + + + + +
+ # + + @lang("{{moduleNameLower}}::text.name") + + @lang("{{moduleNameLower}}::text.updated_at") + + @lang("{{moduleNameLower}}::text.action") +
+
+
+
+ +
+ +@endsection + +@push ('after-styles') + + + +@endpush + +@push ('after-scripts') + + + + +@endpush \ No newline at end of file diff --git a/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/show.blade.stub b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/show.blade.stub new file mode 100644 index 000000000..aedaa14d2 --- /dev/null +++ b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/show.blade.stub @@ -0,0 +1,56 @@ +@extends('backend.layouts.app') + +@section('title') {{ __($module_action) }} {{ __($module_title) }} @endsection + +@section('breadcrumbs') + + + {{ __($module_title) }} + + {{ __($module_action) }} + +@endsection + +@section('content') +
+
+ + + {{ __($module_title) }} {{ __($module_action) }} + + + @lang(":module_name Management Dashboard", ['module_name'=>Str::title($module_name)]) + + + + List + @can('edit_'.$module_name) + + @endcan + + + +
+ +
+
+ + @include('backend.includes.show') + +
+
+
+ + +
+ +@endsection \ No newline at end of file diff --git a/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/trash.blade.stub b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/trash.blade.stub new file mode 100644 index 000000000..1a59e43c7 --- /dev/null +++ b/stubs/laravel-starter-stubs/Resources/views/backend/stubViews/trash.blade.stub @@ -0,0 +1,96 @@ +@extends ('backend.layouts.app') + +@section('title') {{ __($module_action) }} {{ __($module_title) }} @endsection + +@section('breadcrumbs') + + {{ __($module_title) }} + +@endsection + +@section('content') +
+
+ + + {{ __($module_title) }} {{ __($module_action) }} + + + @lang(":module_name Management Dashboard", ['module_name'=>Str::title($module_name)]) + + + + List + + + +
+
+ + + + + + + + + + + + + @foreach($$module_name as $module_name_singular) + + + + + + + + @endforeach + +
+ # + + 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')}} +
+
+
+
+ +
+@endsection + +@section ('after-scripts-end') + +@endsection \ No newline at end of file diff --git a/stubs/laravel-starter-stubs/Resources/views/frontend/stubViews/index.blade.stub b/stubs/laravel-starter-stubs/Resources/views/frontend/stubViews/index.blade.stub new file mode 100644 index 000000000..fe1f140ff --- /dev/null +++ b/stubs/laravel-starter-stubs/Resources/views/frontend/stubViews/index.blade.stub @@ -0,0 +1,63 @@ +@extends('frontend.layouts.app') + +@section('title') {{ __("Tags") }} @endsection + +@section('content') + +
+
+
+

+ {{ __("Tags") }} +

+

+ The list of tags. +

+ + @include('frontend.includes.messages') +
+
+
+ +
+
+ @foreach ($$module_name as $$module_name_singular) + @php + $details_url = route("frontend.$module_name.show",[encode_id($$module_name_singular->id), $$module_name_singular->slug]); + @endphp + +
+
+
+ +

+ {{$$module_name_singular->name}} +

+
+

+ {{$$module_name_singular->description}} +

+

+ Total {{$$module_name_singular->posts->count()}} posts. +

+ + +
+
+
+ + @endforeach +
+
+ {{$$module_name->links()}} +
+
+ +@endsection \ No newline at end of file diff --git a/stubs/laravel-starter-stubs/Resources/views/frontend/stubViews/show.blade.stub b/stubs/laravel-starter-stubs/Resources/views/frontend/stubViews/show.blade.stub new file mode 100644 index 000000000..19a754047 --- /dev/null +++ b/stubs/laravel-starter-stubs/Resources/views/frontend/stubViews/show.blade.stub @@ -0,0 +1,68 @@ +@extends('frontend.layouts.app') + +@section('title') {{$$module_name_singular->name}} - {{ __("Tags") }} @endsection + +@section('content') + +
+
+
+

+ + {{ __("Tags") }} + +

+

+ {{$$module_name_singular->name}} +

+

+ {{$$module_name_singular->description}} +

+ + @include('frontend.includes.messages') +
+
+
+ +
+
+ @foreach ($posts as $post) + @php + $details_url = route("frontend.posts.show",[encode_id($post->id), $post->slug]); + @endphp + +
+
+ + {{$post->name}} + +
+ +

+ {{$post->name}} +

+
+

+ {{$post->intro}} +

+ + +
+
+
+ + @endforeach +
+
+ {{$posts->links()}} +
+
+ +@endsection \ No newline at end of file diff --git a/stubs/laravel-starter-stubs/Tests/Feature/.gitkeep b/stubs/laravel-starter-stubs/Tests/Feature/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/stubs/laravel-starter-stubs/Tests/Unit/.gitkeep b/stubs/laravel-starter-stubs/Tests/Unit/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/stubs/module-stubs/composer.stub b/stubs/laravel-starter-stubs/composer.stub similarity index 58% rename from stubs/module-stubs/composer.stub rename to stubs/laravel-starter-stubs/composer.stub index 8df9e6313..11d089259 100644 --- a/stubs/module-stubs/composer.stub +++ b/stubs/laravel-starter-stubs/composer.stub @@ -1,11 +1,11 @@ { - "name": "$VENDOR$/$LOWER_NAME$", + "name": "{{composerVendor}}/{{moduleNameLower}}", "description": "", "type": "laravel-module", "authors": [ { - "name": "$AUTHOR_NAME$", - "email": "$AUTHOR_EMAIL$" + "name": "{{composerAuthor}}", + "email": "{{composerAuthorEmail}}" } ], "extra": { @@ -18,7 +18,7 @@ }, "autoload": { "psr-4": { - "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": "" + "{{namespace}}\\{{moduleName}}\\": "" } } } diff --git a/stubs/laravel-starter-stubs/database/factories/stubFactory.stub b/stubs/laravel-starter-stubs/database/factories/stubFactory.stub new file mode 100644 index 000000000..621baac92 --- /dev/null +++ b/stubs/laravel-starter-stubs/database/factories/stubFactory.stub @@ -0,0 +1,36 @@ + + */ +class {{moduleName}}Factory extends Factory +{ + /** + * The name of the factory's corresponding model. + * + * @var string + */ + protected $model = \{{namespace}}\{{moduleName}}\Models\{{moduleName}}::class; + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'name' => substr($this->faker->text(15), 0, -1), + 'slug' => '', + 'description' => $this->faker->paragraph, + 'status' => 1, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ]; + } +} diff --git a/stubs/laravel-starter-stubs/database/migrations/stubMigration.stub b/stubs/laravel-starter-stubs/database/migrations/stubMigration.stub new file mode 100644 index 000000000..071eec44c --- /dev/null +++ b/stubs/laravel-starter-stubs/database/migrations/stubMigration.stub @@ -0,0 +1,42 @@ +id(); + + $table->string('name'); + $table->string('slug')->nullable(); + $table->text('description')->nullable(); + $table->tinyInteger('status')->default(1); + + $table->integer('created_by')->unsigned()->nullable(); + $table->integer('updated_by')->unsigned()->nullable(); + $table->integer('deleted_by')->unsigned()->nullable(); + + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('{{moduleNameLowerPlural}}'); + } +}; diff --git a/stubs/laravel-starter-stubs/database/seeders/stubSeeders.stub b/stubs/laravel-starter-stubs/database/seeders/stubSeeders.stub new file mode 100644 index 000000000..8a077e1d7 --- /dev/null +++ b/stubs/laravel-starter-stubs/database/seeders/stubSeeders.stub @@ -0,0 +1,36 @@ +truncate(); + // echo "Truncate: {{moduleNameLowerPlural}} \n"; + + {{moduleName}}::factory()->count(20)->create(); + $rows = {{moduleName}}::all(); + echo " Insert: {{moduleNameLowerPlural}} \n\n"; + + // Enable foreign key checks! + DB::statement('SET FOREIGN_KEY_CHECKS=1;'); + } +} diff --git a/stubs/laravel-starter-stubs/lang/en/text.stub b/stubs/laravel-starter-stubs/lang/en/text.stub new file mode 100644 index 000000000..ab86a0e9f --- /dev/null +++ b/stubs/laravel-starter-stubs/lang/en/text.stub @@ -0,0 +1,15 @@ + 'Name', + 'slug' => 'Slug', + 'description' => 'Description', + 'status' => 'Status', + 'created_by' => 'Created By', + 'updated_at' => 'Updated At', + 'updated_by' => 'Updated By', + 'deleted_by' => 'Deleted By', + 'action' => 'Action', + +]; \ No newline at end of file diff --git a/stubs/laravel-starter-stubs/module.stub b/stubs/laravel-starter-stubs/module.stub new file mode 100644 index 000000000..96006d9b8 --- /dev/null +++ b/stubs/laravel-starter-stubs/module.stub @@ -0,0 +1,13 @@ +{ + "name": "{{moduleName}}", + "alias": "{{moduleNameLower}}", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "{{namespace}}\\{{moduleName}}\\Providers\\{{moduleName}}ServiceProvider" + ], + "aliases": {}, + "files": [], + "requires": [] +} diff --git a/stubs/module-stubs/package.stub b/stubs/laravel-starter-stubs/package.json similarity index 100% rename from stubs/module-stubs/package.stub rename to stubs/laravel-starter-stubs/package.json diff --git a/stubs/laravel-starter-stubs/routes/.gitkeep b/stubs/laravel-starter-stubs/routes/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/stubs/module-stubs/routes/api.stub b/stubs/laravel-starter-stubs/routes/api.stub similarity index 83% rename from stubs/module-stubs/routes/api.stub rename to stubs/laravel-starter-stubs/routes/api.stub index 4a6eb220d..3ab45117d 100644 --- a/stubs/module-stubs/routes/api.stub +++ b/stubs/laravel-starter-stubs/routes/api.stub @@ -14,6 +14,6 @@ use Illuminate\Support\Facades\Route; | */ -Route::middleware('auth:api')->get('/$LOWER_NAME$', function (Request $request) { +Route::middleware('auth:api')->get('/{{moduleNameLowerPlural}}', function (Request $request) { return $request->user(); -}); \ No newline at end of file +}); diff --git a/stubs/laravel-starter-stubs/routes/web.stub b/stubs/laravel-starter-stubs/routes/web.stub new file mode 100644 index 000000000..f588f904d --- /dev/null +++ b/stubs/laravel-starter-stubs/routes/web.stub @@ -0,0 +1,64 @@ + '\{{namespace}}\{{moduleName}}\Http\Controllers\Frontend', 'as' => 'frontend.', 'middleware' => 'web', 'prefix' => ''], function () { + + /* + * + * Frontend {{moduleNamePlural}} Routes + * + * --------------------------------------------------------------------- + */ + $module_name = '{{moduleNameLowerPlural}}'; + $controller_name = '{{moduleNamePlural}}Controller'; + Route::get("$module_name", ['as' => "$module_name.index", 'uses' => "$controller_name@index"]); + Route::get("$module_name/{id}/{slug?}", ['as' => "$module_name.show", 'uses' => "$controller_name@show"]); +}); + +/* +* +* Backend Routes +* +* -------------------------------------------------------------------- +*/ +Route::group(['namespace' => '\{{namespace}}\{{moduleName}}\Http\Controllers\Backend', 'as' => 'backend.', 'middleware' => ['web', 'auth', 'can:view_backend'], 'prefix' => 'admin'], function () { + /* + * These routes need view-backend permission + * (good if you want to allow more than one group in the backend, + * then limit the backend features by different roles or permissions) + * + * Note: Administrator has all permissions so you do not have to specify the administrator role everywhere. + */ + + /* + * + * Backend {{moduleNamePlural}} Routes + * + * --------------------------------------------------------------------- + */ + $module_name = '{{moduleNameLowerPlural}}'; + $controller_name = '{{moduleNamePlural}}Controller'; + Route::get("$module_name/index_list", ['as' => "$module_name.index_list", 'uses' => "$controller_name@index_list"]); + Route::get("$module_name/index_data", ['as' => "$module_name.index_data", 'uses' => "$controller_name@index_data"]); + Route::get("$module_name/trashed", ['as' => "$module_name.trashed", 'uses' => "$controller_name@trashed"]); + Route::patch("$module_name/trashed/{id}", ['as' => "$module_name.restore", 'uses' => "$controller_name@restore"]); + Route::resource("$module_name", "$controller_name"); +}); diff --git a/stubs/module-stubs/webpack.stub b/stubs/laravel-starter-stubs/webpack.mix.js similarity index 66% rename from stubs/module-stubs/webpack.stub rename to stubs/laravel-starter-stubs/webpack.mix.js index 639a55323..20112d6b8 100644 --- a/stubs/module-stubs/webpack.stub +++ b/stubs/laravel-starter-stubs/webpack.mix.js @@ -6,8 +6,8 @@ require('laravel-mix-merge-manifest'); mix.setPublicPath('../../public').mergeManifest(); -mix.js(__dirname + '/Resources/assets/js/app.js', 'js/$LOWER_NAME$.js') - .sass( __dirname + '/Resources/assets/sass/app.scss', 'css/$LOWER_NAME$.css'); +mix.js(__dirname + '/Resources/assets/js/app.js', 'js/tag.js') + .sass( __dirname + '/Resources/assets/sass/app.scss', 'css/tag.css'); if (mix.inProduction()) { mix.version(); diff --git a/stubs/module-stubs/command.stub b/stubs/module-stubs/command.stub deleted file mode 100644 index 87469deec..000000000 --- a/stubs/module-stubs/command.stub +++ /dev/null @@ -1,68 +0,0 @@ - - - diff --git a/stubs/module-stubs/controller-api.stub b/stubs/module-stubs/controller-api.stub deleted file mode 100644 index 8cdac7c82..000000000 --- a/stubs/module-stubs/controller-api.stub +++ /dev/null @@ -1,60 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/stubs/module-stubs/job-queued.stub b/stubs/module-stubs/job-queued.stub deleted file mode 100644 index 5bcccf1a2..000000000 --- a/stubs/module-stubs/job-queued.stub +++ /dev/null @@ -1,34 +0,0 @@ -view('view.name'); - } -} diff --git a/stubs/module-stubs/middleware.stub b/stubs/module-stubs/middleware.stub deleted file mode 100644 index 954583ed4..000000000 --- a/stubs/module-stubs/middleware.stub +++ /dev/null @@ -1,21 +0,0 @@ -id(); -$FIELDS$ - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('$TABLE$'); - } -}; diff --git a/stubs/module-stubs/migration/delete.stub b/stubs/module-stubs/migration/delete.stub deleted file mode 100644 index 4d1e064ad..000000000 --- a/stubs/module-stubs/migration/delete.stub +++ /dev/null @@ -1,32 +0,0 @@ -bigIncrements('id'); -$FIELDS$ - $table->timestamps(); - }); - } -}; diff --git a/stubs/module-stubs/migration/plain.stub b/stubs/module-stubs/migration/plain.stub deleted file mode 100644 index e46b052fc..000000000 --- a/stubs/module-stubs/migration/plain.stub +++ /dev/null @@ -1,28 +0,0 @@ -line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } -} diff --git a/stubs/module-stubs/policy.plain.stub b/stubs/module-stubs/policy.plain.stub deleted file mode 100644 index 02e16df36..000000000 --- a/stubs/module-stubs/policy.plain.stub +++ /dev/null @@ -1,20 +0,0 @@ -group(function() { - Route::get('/', '$STUDLY_NAME$Controller@index'); -}); diff --git a/stubs/module-stubs/rule.stub b/stubs/module-stubs/rule.stub deleted file mode 100644 index 9b716321e..000000000 --- a/stubs/module-stubs/rule.stub +++ /dev/null @@ -1,40 +0,0 @@ - '$STUDLY_NAME$' -]; diff --git a/stubs/module-stubs/seeder.stub b/stubs/module-stubs/seeder.stub deleted file mode 100644 index f35057de3..000000000 --- a/stubs/module-stubs/seeder.stub +++ /dev/null @@ -1,21 +0,0 @@ -call("OthersTableSeeder"); - } -} diff --git a/stubs/module-stubs/unit-test.stub b/stubs/module-stubs/unit-test.stub deleted file mode 100644 index be0bd559b..000000000 --- a/stubs/module-stubs/unit-test.stub +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} diff --git a/stubs/module-stubs/views/index.stub b/stubs/module-stubs/views/index.stub deleted file mode 100644 index 04b928889..000000000 --- a/stubs/module-stubs/views/index.stub +++ /dev/null @@ -1,9 +0,0 @@ -@extends('$LOWER_NAME$::layouts.master') - -@section('content') -

Hello World

- -

- 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 @@ - - - - - - - Module $STUDLY_NAME$ - - {{-- Laravel Mix - CSS File --}} - {{-- --}} - - - - @yield('content') - - {{-- Laravel Mix - JS File --}} - {{-- --}} - -