Skip to content

Commit a4679d4

Browse files
authored
Merge pull request #360 from nasirkhan/update
nasirkhan/module-manager package installed
2 parents 7679a96 + 404c557 commit a4679d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1313
-1130
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"lavary/laravel-menu": "^1.8",
2020
"livewire/livewire": "^2.10",
2121
"mews/purifier": "^3.3",
22+
"nasirkhan/module-manager": "^0.3.0",
2223
"nwidart/laravel-modules": "^9.0",
2324
"predis/predis": "^1.1",
2425
"spatie/laravel-activitylog": "^4.5",

composer.lock

Lines changed: 72 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/module-manager.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Module Config
8+
|--------------------------------------------------------------------------
9+
|
10+
*/
11+
12+
'namespace' => 'Modules',
13+
14+
'stubs' => [
15+
'path' => base_path('stubs/laravel-starter-stubs'),
16+
],
17+
18+
'module' => [
19+
'files' => [
20+
'composer' => ['composer.stub', 'composer.json'],
21+
'json' => ['module.stub', 'module.json'],
22+
'config' => ['Config/config.stub', 'Config/config.php'],
23+
'database' => ['database/migrations/stubMigration.stub', 'database/migrations/stubMigration.php', 'rename'],
24+
'factories' => ['database/factories/stubFactory.stub', 'database/factories/stubFactory.php', 'rename'],
25+
'seeders' => ['database/seeders/stubSeeders.stub', 'database/seeders/stubSeeders.php', 'rename'],
26+
'command' => ['Console/Commands/StubCommand.stub', 'Console/Commands/StubCommand.php', 'rename'],
27+
'lang' => ['lang/en/text.stub', 'lang/en/text.php'],
28+
'models' => ['Models/stubModel.stub', 'Models/stubModel.php'],
29+
'providersRoute' => ['Providers/RouteServiceProvider.stub', 'Providers/RouteServiceProvider.php'],
30+
'providers' => ['Providers/stubServiceProvider.stub', 'Providers/stubServiceProvider.php'],
31+
'route_web' => ['routes/web.stub', 'routes/web.php'],
32+
'route_api' => ['routes/api.stub', 'routes/api.php'],
33+
'controller_backend' => ['Http/Controllers/Backend/stubBackendController.stub', 'Http/Controllers/Backend/stubBackendController.php'],
34+
'controller_frontend' => ['Http/Controllers/Frontend/stubFrontendController.stub', 'Http/Controllers/Frontend/stubFrontendController.php'],
35+
'middleware_menu' => ['Http/Middleware/GenerateMenus.stub', 'Http/Middleware/GenerateMenus.php'],
36+
'views_backend_index' => ['Resources/views/backend/stubViews/index.blade.stub', 'Resources/views/backend/stubViews/index.blade.php'],
37+
'views_backend_index_datatable' => ['Resources/views/backend/stubViews/index_datatable.blade.stub', 'Resources/views/backend/stubViews/index_datatable.blade.php'],
38+
'views_backend_create' => ['Resources/views/backend/stubViews/create.blade.stub', 'Resources/views/backend/stubViews/create.blade.php'],
39+
'views_backend_form' => ['Resources/views/backend/stubViews/form.blade.stub', 'Resources/views/backend/stubViews/form.blade.php'],
40+
'views_backend_show' => ['Resources/views/backend/stubViews/show.blade.stub', 'Resources/views/backend/stubViews/show.blade.php'],
41+
'views_backend_edit' => ['Resources/views/backend/stubViews/edit.blade.stub', 'Resources/views/backend/stubViews/edit.blade.php'],
42+
'views_backend_trash' => ['Resources/views/backend/stubViews/trash.blade.stub', 'Resources/views/backend/stubViews/trash.blade.php'],
43+
'views_frontend_index' => ['Resources/views/frontend/stubViews/index.blade.stub', 'Resources/views/frontend/stubViews/index.blade.php'],
44+
'views_frontend_show' => ['Resources/views/frontend/stubViews/show.blade.stub', 'Resources/views/frontend/stubViews/show.blade.php'],
45+
],
46+
],
47+
48+
/*
49+
|--------------------------------------------------------------------------
50+
| Module Composer
51+
|--------------------------------------------------------------------------
52+
|
53+
| Config for the composer.json file
54+
|
55+
*/
56+
57+
'composer' => [
58+
'vendor' => 'nasirkhan',
59+
'author' => [
60+
'name' => 'Nasir Khan',
61+
'email' => 'nasir8891@gmail.com',
62+
],
63+
],
64+
];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'name' => '{{moduleName}}',
5+
];
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace {{namespace}}\{{moduleName}}\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class {{moduleName}}Command extends Command
8+
{
9+
/**
10+
* The name and signature of the console command.
11+
*
12+
* @var string
13+
*/
14+
protected $signature = 'command:{{moduleName}}Command';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = '{{moduleName}} Command description';
22+
23+
/**
24+
* Execute the console command.
25+
*
26+
* @return int
27+
*/
28+
public function handle()
29+
{
30+
return Command::SUCCESS;
31+
}
32+
}

stubs/laravel-starter-stubs/Http/Controllers/.gitkeep

Whitespace-only changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace {{namespace}}\{{moduleName}}\Http\Controllers\Backend;
4+
5+
use App\Authorizable;
6+
use App\Http\Controllers\Backend\BackendBaseController;
7+
8+
class {{moduleNamePlural}}Controller extends BackendBaseController
9+
{
10+
use Authorizable;
11+
12+
public function __construct()
13+
{
14+
// Page Title
15+
$this->module_title = '{{moduleNamePlural}}';
16+
17+
// module name
18+
$this->module_name = '{{moduleNameLowerPlural}}';
19+
20+
// directory path of the module
21+
$this->module_path = '{{moduleNameLower}}::backend';
22+
23+
// module icon
24+
$this->module_icon = 'fa-regular fa-sun';
25+
26+
// module model name, path
27+
$this->module_model = "{{namespace}}\{{moduleName}}\Models\{{moduleName}}";
28+
}
29+
30+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
namespace {{namespace}}\{{moduleName}}\Http\Controllers\Frontend;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Http\Response;
7+
use Illuminate\Support\Str;
8+
9+
class {{moduleNamePlural}}Controller extends Controller
10+
{
11+
public function __construct()
12+
{
13+
// Page Title
14+
$this->module_title = '{{moduleNamePlural}}';
15+
16+
// module name
17+
$this->module_name = '{{moduleNameLowerPlural}}';
18+
19+
// directory path of the module
20+
$this->module_path = '{{moduleNameLower}}::backend';
21+
22+
// module icon
23+
$this->module_icon = 'fa-regular fa-sun';
24+
25+
// module model name, path
26+
$this->module_model = "{{namespace}}\{{moduleName}}\Models\{{moduleName}}";
27+
}
28+
29+
/**
30+
* Display a listing of the resource.
31+
*
32+
* @return Response
33+
*/
34+
public function index()
35+
{
36+
$module_title = $this->module_title;
37+
$module_name = $this->module_name;
38+
$module_path = $this->module_path;
39+
$module_icon = $this->module_icon;
40+
$module_model = $this->module_model;
41+
$module_name_singular = Str::singular($module_name);
42+
43+
$module_action = 'List';
44+
45+
$$module_name = $module_model::latest()->paginate();
46+
47+
return view(
48+
"{{moduleNameLower}}::frontend.$module_path.index",
49+
compact('module_title', 'module_name', "$module_name", 'module_icon', 'module_action', 'module_name_singular')
50+
);
51+
}
52+
53+
/**
54+
* Display the specified resource.
55+
*
56+
* @param int $id
57+
* @return Response
58+
*/
59+
public function show($id)
60+
{
61+
$id = decode_id($id);
62+
63+
$module_title = $this->module_title;
64+
$module_name = $this->module_name;
65+
$module_path = $this->module_path;
66+
$module_icon = $this->module_icon;
67+
$module_model = $this->module_model;
68+
$module_name_singular = Str::singular($module_name);
69+
70+
$module_action = 'Show';
71+
72+
$$module_name_singular = $module_model::findOrFail($id);
73+
74+
return view(
75+
"{{moduleNameLower}}::frontend.$module_name.show",
76+
compact('module_title', 'module_name', 'module_icon', 'module_action', 'module_name_singular', "$module_name_singular", 'posts')
77+
);
78+
}
79+
}

stubs/laravel-starter-stubs/Http/Middleware/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)