-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8e6fe2b
Showing
31 changed files
with
664 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
'name' => 'Menu' | ||
]; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace Modules\Menu\Console; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\File; | ||
use Modules\Base\Services\Core\VILT; | ||
use Illuminate\Support\Facades\Artisan; | ||
|
||
class InstallMenu extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'menu:install'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Install menu permissions to main admin role'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$this->info('Install Permissions'); | ||
Artisan::call('roles:generate menus'); | ||
$this->info('Your Menu is ready now'); | ||
$menus = VILT::loadMenu(); | ||
$menuPath = base_path('menu.json'); | ||
$check = File::exists($menuPath); | ||
if (!$check) { | ||
File::put($menuPath, json_encode($menus)); | ||
} | ||
|
||
return Command::SUCCESS; | ||
} | ||
|
||
/** | ||
* Get the console command arguments. | ||
* | ||
* @return array | ||
*/ | ||
protected function getArguments() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the console command options. | ||
* | ||
* @return array | ||
*/ | ||
protected function getOptions() | ||
{ | ||
return []; | ||
} | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Modules\Menu\Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class MenuDatabaseSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
Model::unguard(); | ||
|
||
// $this->call("OthersTableSeeder"); | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright 2022 info@3x1.io | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
|
||
namespace Modules\Menu\Pages; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\File; | ||
use Modules\Base\Services\Core\VILT; | ||
use Modules\Base\Services\Resource\Page; | ||
use Modules\Base\Services\Components\Base\Render; | ||
use Modules\Base\Services\Components\Base\Component; | ||
|
||
class MenusPage extends Page | ||
{ | ||
public ?string $path = "menus"; | ||
public ?string $group = "Settings"; | ||
public ?string $icon = "bx bx-menu"; | ||
|
||
public function index() | ||
{ | ||
$menus = VILT::loadMenu(); | ||
$menuPath = base_path('menu.json'); | ||
$check = File::exists($menuPath); | ||
if (!$check) { | ||
File::put($menuPath, json_encode($menus)); | ||
} | ||
|
||
$menuFile = json_decode(File::get($menuPath)); | ||
return Render::make('Menus')->module('Menu')->data([ | ||
"menu" => $menuFile, | ||
"title" => __('Menus'), | ||
"back" => __('Back'), | ||
])->render(); | ||
} | ||
|
||
public function move(Request $request) | ||
{ | ||
$menu = $request->get('menu'); | ||
$name = $request->get('name'); | ||
$menuPath = base_path('menu.json'); | ||
$getMenu = json_decode(File::get($menuPath)); | ||
foreach ($getMenu as $key => $item) { | ||
if ($key === $name) { | ||
$getMenu->{$name} = $menu; | ||
} | ||
} | ||
File::delete($menuPath); | ||
File::put($menuPath, json_encode($getMenu)); | ||
|
||
return response()->json([ | ||
"status" => "success", | ||
"message" => "Menu has been updated" | ||
]); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
|
||
namespace Modules\Menu\Providers; | ||
|
||
use Modules\Base\Services\Core\VILT; | ||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Database\Eloquent\Factory; | ||
use Illuminate\Support\Facades\File; | ||
use Modules\Base\Services\Components\Base\Lang; | ||
use Modules\Base\Services\Components\Base\Menu; | ||
use Modules\Menu\Console\InstallMenu; | ||
|
||
class MenuServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* @var string $moduleName | ||
*/ | ||
protected $moduleName = 'Menu'; | ||
|
||
/** | ||
* @var string $moduleNameLower | ||
*/ | ||
protected $moduleNameLower = 'menu'; | ||
|
||
/** | ||
* Boot the application events. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->registerTranslations(); | ||
$this->registerConfig(); | ||
$this->registerViews(); | ||
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); | ||
VILT::loadResources($this->moduleName); | ||
VILT::loadPages($this->moduleName); | ||
VILT::registerTranslation(Lang::make('menus.sidebar')->label(__('Menus'))); | ||
|
||
$this->commands([ | ||
InstallMenu::class | ||
]); | ||
} | ||
|
||
/** | ||
* Register the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->register(RouteServiceProvider::class); | ||
} | ||
|
||
/** | ||
* Register config. | ||
* | ||
* @return void | ||
*/ | ||
protected function registerConfig() | ||
{ | ||
$this->publishes([ | ||
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'), | ||
], 'config'); | ||
$this->mergeConfigFrom( | ||
module_path($this->moduleName, 'Config/config.php'), | ||
$this->moduleNameLower | ||
); | ||
} | ||
|
||
/** | ||
* Register views. | ||
* | ||
* @return void | ||
*/ | ||
public function registerViews() | ||
{ | ||
$viewPath = resource_path('views/modules/' . $this->moduleNameLower); | ||
|
||
$sourcePath = module_path($this->moduleName, 'Resources/views'); | ||
|
||
$this->publishes([ | ||
$sourcePath => $viewPath | ||
], ['views', $this->moduleNameLower . '-module-views']); | ||
|
||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); | ||
} | ||
|
||
/** | ||
* Register translations. | ||
* | ||
* @return void | ||
*/ | ||
public function registerTranslations() | ||
{ | ||
$langPath = resource_path('lang/modules/' . $this->moduleNameLower); | ||
|
||
if (is_dir($langPath)) { | ||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower); | ||
$this->loadJsonTranslationsFrom($langPath, $this->moduleNameLower); | ||
} else { | ||
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); | ||
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower); | ||
} | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return []; | ||
} | ||
|
||
private function getPublishableViewPaths(): array | ||
{ | ||
$paths = []; | ||
foreach (\Config::get('view.paths') as $path) { | ||
if (is_dir($path . '/modules/' . $this->moduleNameLower)) { | ||
$paths[] = $path . '/modules/' . $this->moduleNameLower; | ||
} | ||
} | ||
return $paths; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Modules\Menu\Providers; | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; | ||
|
||
class RouteServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* The module namespace to assume when generating URLs to actions. | ||
* | ||
* @var string | ||
*/ | ||
protected $moduleNamespace = 'Modules\Menu\Http\Controllers'; | ||
|
||
/** | ||
* Called before routes are registered. | ||
* | ||
* Register any model bindings or pattern based filters. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
parent::boot(); | ||
} | ||
|
||
/** | ||
* Define the routes for the application. | ||
* | ||
* @return void | ||
*/ | ||
public function map() | ||
{ | ||
$this->mapApiRoutes(); | ||
|
||
$this->mapWebRoutes(); | ||
} | ||
|
||
/** | ||
* Define the "web" routes for the application. | ||
* | ||
* These routes all receive session state, CSRF protection, etc. | ||
* | ||
* @return void | ||
*/ | ||
protected function mapWebRoutes() | ||
{ | ||
Route::middleware('web') | ||
->namespace($this->moduleNamespace) | ||
->group(module_path('Menu', '/Routes/web.php')); | ||
} | ||
|
||
/** | ||
* Define the "api" routes for the application. | ||
* | ||
* These routes are typically stateless. | ||
* | ||
* @return void | ||
*/ | ||
protected function mapApiRoutes() | ||
{ | ||
Route::prefix('api') | ||
->middleware('api') | ||
->namespace($this->moduleNamespace) | ||
->group(module_path('Menu', '/Routes/api.php')); | ||
} | ||
} |
Oops, something went wrong.