Skip to content

Commit

Permalink
Merge pull request #360 from nasirkhan/update
Browse files Browse the repository at this point in the history
nasirkhan/module-manager package installed
  • Loading branch information
nasirkhan authored Nov 15, 2022
2 parents 7679a96 + 404c557 commit a4679d4
Show file tree
Hide file tree
Showing 79 changed files with 1,313 additions and 1,130 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
86 changes: 72 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions config/module-manager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Module Config
|--------------------------------------------------------------------------
|
*/

'namespace' => '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' => '[email protected]',
],
],
];
File renamed without changes.
5 changes: 5 additions & 0 deletions stubs/laravel-starter-stubs/Config/config.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'name' => '{{moduleName}}',
];
File renamed without changes.
32 changes: 32 additions & 0 deletions stubs/laravel-starter-stubs/Console/Commands/StubCommand.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace {{namespace}}\{{moduleName}}\Console\Commands;

use Illuminate\Console\Command;

class {{moduleName}}Command extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:{{moduleName}}Command';

/**
* The console command description.
*
* @var string
*/
protected $description = '{{moduleName}} Command description';

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
return Command::SUCCESS;
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace {{namespace}}\{{moduleName}}\Http\Controllers\Backend;

use App\Authorizable;
use App\Http\Controllers\Backend\BackendBaseController;

class {{moduleNamePlural}}Controller extends BackendBaseController
{
use Authorizable;

public function __construct()
{
// Page Title
$this->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}}";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace {{namespace}}\{{moduleName}}\Http\Controllers\Frontend;

use App\Http\Controllers\Controller;
use Illuminate\Http\Response;
use Illuminate\Support\Str;

class {{moduleNamePlural}}Controller extends Controller
{
public function __construct()
{
// Page Title
$this->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')
);
}
}
Empty file.
Loading

0 comments on commit a4679d4

Please sign in to comment.