* Update module generation #714 * Fix method signatures * Fix paths within stubs, use single provider.stub file * Add separate index controller * Update module generation #714 * Fix method signatures * Fix paths within stubs, use single provider.stub file * Update module generation Disable/lower the cache time as found as a workaround in https://github.com/nWidart/laravel-modules/issues/995 * Update editorconfig for line endings * Formatting * Formatting
This commit is contained in:
parent
435fa32663
commit
77fe6679ce
@ -27,4 +27,4 @@ indent_style = tab
|
||||
# Matches the exact files either package.json or .travis.yml
|
||||
[{package.json, .travis.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
indent_size = 2
|
49
app/Contracts/Modules/ServiceProvider.php
Normal file
49
app/Contracts/Modules/ServiceProvider.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts\Modules;
|
||||
|
||||
/**
|
||||
* Base class for module service providers
|
||||
* Add-on module service providers must extend this class. Docs on Service Providers:
|
||||
* https://laravel.com/docs/7.x/providers
|
||||
*
|
||||
* For a sample service provider, view the sample module one:
|
||||
* https://github.com/nabeelio/phpvms-module/blob/master/Providers/SampleServiceProvider.php
|
||||
*/
|
||||
abstract class ServiceProvider extends \Illuminate\Support\ServiceProvider
|
||||
{
|
||||
/**
|
||||
* A boot method is required, even if it doesn't do anything.
|
||||
* https://laravel.com/docs/7.x/providers#the-boot-method
|
||||
*
|
||||
* This is normally where you'd register the routes or other startup tasks for your module
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This is required to register the links in either the public or admin toolbar
|
||||
* For example, adding a frontend link:
|
||||
*
|
||||
* $this->moduleSvc->addFrontendLink('Sample', '/sample', '', $logged_in=true);
|
||||
*
|
||||
* Or an admin link:
|
||||
*
|
||||
* $this->moduleSvc->addAdminLink('Sample', '/admin/sample');
|
||||
*/
|
||||
public function registerLinks(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Deferred providers:
|
||||
* https://laravel.com/docs/7.x/providers#deferred-providers
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -17,9 +17,10 @@ return [
|
||||
'views/frontend' => 'Resources/views/layouts/frontend.blade.php',
|
||||
'views/admin' => 'Resources/views/layouts/admin.blade.php',
|
||||
'listener-test' => 'Listeners/TestEventListener.php',
|
||||
'controller-index' => 'Http/Controllers/Frontend/IndexController.php',
|
||||
'controller-api' => 'Http/Controllers/Api/ApiController.php',
|
||||
'controller-admin' => 'Http/Controllers/Admin/AdminController.php',
|
||||
'scaffold/config' => 'Config/config.php',
|
||||
'config' => 'Config/config.php',
|
||||
'composer' => 'composer.json',
|
||||
],
|
||||
'replacements' => [
|
||||
@ -27,22 +28,45 @@ return [
|
||||
'routes' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'routes-api' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'event-service-provider' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'listener-test' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'views/index' => ['LOWER_NAME'],
|
||||
'views/index-admin' => ['LOWER_NAME', 'STUDLY_NAME'],
|
||||
'views/frontend' => ['STUDLY_NAME'],
|
||||
'views/admin' => ['STUDLY_NAME'],
|
||||
'controller-admin' => ['MODULE_NAMESPACE', 'STUDLY_NAME', 'CLASS_NAMESPACE', 'LOWER_NAME'],
|
||||
'controller-api' => ['MODULE_NAMESPACE', 'STUDLY_NAME', 'CLASS_NAMESPACE', 'LOWER_NAME'],
|
||||
'scaffold/config' => ['STUDLY_NAME'],
|
||||
'composer' => [
|
||||
'provider' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'event-service-provider' => [
|
||||
'LOWER_NAME',
|
||||
'STUDLY_NAME',
|
||||
'MODULE_NAMESPACE',
|
||||
'CLASS_NAMESPACE',
|
||||
],
|
||||
'listener-test' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||
'views/index' => ['LOWER_NAME'],
|
||||
'views/index-admin' => ['LOWER_NAME', 'STUDLY_NAME'],
|
||||
'views/frontend' => ['STUDLY_NAME'],
|
||||
'views/admin' => ['STUDLY_NAME'],
|
||||
'controller-index' => [
|
||||
'MODULE_NAMESPACE',
|
||||
'STUDLY_NAME',
|
||||
'CLASS_NAMESPACE',
|
||||
'LOWER_NAME',
|
||||
],
|
||||
'controller-admin' => [
|
||||
'MODULE_NAMESPACE',
|
||||
'STUDLY_NAME',
|
||||
'CLASS_NAMESPACE',
|
||||
'LOWER_NAME',
|
||||
],
|
||||
'controller-api' => [
|
||||
'MODULE_NAMESPACE',
|
||||
'STUDLY_NAME',
|
||||
'CLASS_NAMESPACE',
|
||||
'LOWER_NAME',
|
||||
],
|
||||
'config' => ['STUDLY_NAME'],
|
||||
'composer' => [
|
||||
'LOWER_NAME',
|
||||
'STUDLY_NAME',
|
||||
'VENDOR',
|
||||
'AUTHOR_NAME',
|
||||
'AUTHOR_EMAIL',
|
||||
'MODULE_NAMESPACE',
|
||||
'PROVIDER_NAMESPACE',
|
||||
],
|
||||
],
|
||||
'gitkeep' => false,
|
||||
@ -52,15 +76,16 @@ return [
|
||||
'assets' => public_path('modules'),
|
||||
'migration' => base_path('database/migrations'),
|
||||
'generator' => [
|
||||
'config' => ['path' => 'Config', 'generate' => true],
|
||||
'command' => ['path' => 'Console', 'generate' => true],
|
||||
'migration' => ['path' => 'Database/migrations', 'generate' => true],
|
||||
'seeds' => ['path' => 'Database/seeds', 'generate' => true],
|
||||
'factory' => ['path' => 'Database/factories', 'generate' => true],
|
||||
'model' => ['path' => 'Models', 'generate' => true],
|
||||
'controller' => ['path' => 'Http/Controllers', 'generate' => true],
|
||||
'config' => ['path' => 'Config', 'generate' => true],
|
||||
'command' => ['path' => 'Console', 'generate' => true],
|
||||
'migration' => ['path' => 'Database/migrations', 'generate' => true],
|
||||
'seeds' => ['path' => 'Database/seeds', 'generate' => true],
|
||||
'factory' => ['path' => 'Database/factories', 'generate' => true],
|
||||
'model' => ['path' => 'Models', 'generate' => true],
|
||||
//'controller' => ['path' => 'Http/Controllers', 'generate' => true],
|
||||
'controller-admin' => ['path' => 'Http/Controllers/Admin', 'generate' => true],
|
||||
'controller-api' => ['path' => 'Http/Controllers/Api', 'generate' => true],
|
||||
'controller-index' => ['path' => 'Http/Controllers/Frontend', 'generate' => true],
|
||||
'filter' => ['path' => 'Http/Middleware', 'generate' => true],
|
||||
'request' => ['path' => 'Http/Requests', 'generate' => true],
|
||||
'routes' => ['path' => 'Http/Routes', 'generate' => true],
|
||||
@ -124,7 +149,7 @@ return [
|
||||
'cache' => [
|
||||
'enabled' => true,
|
||||
'key' => 'phpvms-modules',
|
||||
'lifetime' => 10,
|
||||
'lifetime' => 0,
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -143,7 +168,7 @@ return [
|
||||
'class' => FileActivator::class,
|
||||
'statuses-file' => config_path('modules_statuses.json'),
|
||||
'cache-key' => 'activator.installed',
|
||||
'cache-lifetime' => 604800,
|
||||
'cache-lifetime' => 0,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
@ -5,5 +5,6 @@
|
||||
"Sample": true,
|
||||
"Updater": true,
|
||||
"VMSAcars": true,
|
||||
"Vacentral": true
|
||||
}
|
||||
"Vacentral": true,
|
||||
"TestModule": true
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Modules\Awards\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Contracts\Modules\ServiceProvider;
|
||||
|
||||
class AwardServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace Modules\Importer\Providers;
|
||||
|
||||
use App\Contracts\Modules\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Importer\Console\Commands\ImportFromClassicCommand;
|
||||
|
||||
class ImporterServiceProvider extends ServiceProvider
|
||||
@ -11,7 +11,7 @@ class ImporterServiceProvider extends ServiceProvider
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerRoutes();
|
||||
@ -20,6 +20,9 @@ class ImporterServiceProvider extends ServiceProvider
|
||||
$this->registerViews();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register console commands
|
||||
*/
|
||||
protected function registerCommands()
|
||||
{
|
||||
$this->commands([
|
||||
@ -44,7 +47,6 @@ class ImporterServiceProvider extends ServiceProvider
|
||||
|
||||
// Run the actual importer process. Additional middleware
|
||||
Route::post('/run', 'ImporterController@run')->middleware('api')->name('run');
|
||||
|
||||
Route::post('/complete', 'ImporterController@complete')->name('complete');
|
||||
});
|
||||
}
|
||||
@ -91,12 +93,4 @@ class ImporterServiceProvider extends ServiceProvider
|
||||
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'importer');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
namespace Modules\Installer\Providers;
|
||||
|
||||
use App\Contracts\Modules\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class InstallerServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerRoutes();
|
||||
$this->registerTranslations();
|
||||
|
@ -14,8 +14,9 @@
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\$STUDLY_NAME$ServiceProvider",
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\EventServiceProvider"
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\AppServiceProvider",
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\EventServiceProvider",
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\RouteServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
|
||||
|
@ -6,52 +6,71 @@ use App\Contracts\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class AdminController
|
||||
* @package $MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Admin
|
||||
* Admin controller
|
||||
*/
|
||||
class AdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::admin.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function create()
|
||||
public function create(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::admin.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
return view('$LOWER_NAME$::admin.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit()
|
||||
public function edit(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::admin.edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::admin.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
@ -59,8 +78,10 @@ class AdminController extends Controller
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function destroy()
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,9 @@ class ApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* Just send out a message
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
@ -23,7 +25,9 @@ class ApiController extends Controller
|
||||
|
||||
/**
|
||||
* Handles /hello
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function hello(Request $request)
|
||||
|
90
resources/stubs/modules/controller-index.stub
Normal file
90
resources/stubs/modules/controller-index.stub
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Frontend;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class $CLASS$
|
||||
* @package $CLASS_NAMESPACE$
|
||||
*/
|
||||
class IndexController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace $CLASS_NAMESPACE$;
|
||||
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Frontend;
|
||||
|
||||
use App\Contracts\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
@ -13,23 +13,34 @@ class $CLASS$ extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function create()
|
||||
public function create(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
@ -37,22 +48,32 @@ class $CLASS$ extends Controller
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function show()
|
||||
public function show(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit()
|
||||
public function edit(Request $request)
|
||||
{
|
||||
return view('$LOWER_NAME$::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
@ -60,8 +81,10 @@ class $CLASS$ extends Controller
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function destroy()
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,9 @@
|
||||
"active": 1,
|
||||
"order": 0,
|
||||
"providers": [
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\$STUDLY_NAME$ServiceProvider",
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\EventServiceProvider"
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\AppServiceProvider",
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\EventServiceProvider",
|
||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\RouteServiceProvider"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
|
@ -3,12 +3,17 @@
|
||||
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Listeners;
|
||||
|
||||
use App\Events\TestEvent;
|
||||
use Log;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* A sample event listener
|
||||
*/
|
||||
class TestEventListener
|
||||
{
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param \App\Events\TestEvent $event
|
||||
*/
|
||||
public function handle(TestEvent $event) {
|
||||
Log::info('Received event', [$event]);
|
||||
|
@ -1,26 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Contracts\Modules\ServiceProvider;
|
||||
|
||||
/**
|
||||
* Class $CLASS$
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CLASS$ extends ServiceProvider
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $moduleSvc;
|
||||
|
||||
protected $defer = false;
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->moduleSvc = app('App\Services\ModuleService');
|
||||
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
|
||||
$this->registerLinks();
|
||||
|
||||
// Uncomment this if you have migrations
|
||||
// $this->loadMigrationsFrom(__DIR__ . '/../$MIGRATIONS_PATH$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
@ -28,12 +39,55 @@ class $CLASS$ extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
* Add module links here
|
||||
*/
|
||||
public function provides()
|
||||
public function registerLinks(): void
|
||||
{
|
||||
return [];
|
||||
// Show this link if logged in
|
||||
// $this->moduleSvc->addFrontendLink('$STUDLY_NAME$', '/$LOWER_NAME$', '', $logged_in=true);
|
||||
|
||||
// Admin links:
|
||||
$this->moduleSvc->addAdminLink('$STUDLY_NAME$', '/admin/$LOWER_NAME$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__.'/../Config/config.php' => config_path('$LOWER_NAME$.php'),
|
||||
], '$LOWER_NAME$');
|
||||
|
||||
$this->mergeConfigFrom(__DIR__.'/../Config/config.php', '$LOWER_NAME$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews()
|
||||
{
|
||||
$viewPath = resource_path('views/modules/$LOWER_NAME$');
|
||||
$sourcePath = __DIR__.'/../Resources/views';
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath],'views');
|
||||
|
||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||
return $path . '/modules/$LOWER_NAME$';
|
||||
}, \Config::get('view.paths')), [$sourcePath]), '$LOWER_NAME$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations()
|
||||
{
|
||||
$langPath = resource_path('lang/modules/$LOWER_NAME$');
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, '$LOWER_NAME$');
|
||||
} else {
|
||||
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', '$LOWER_NAME$');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,19 +4,19 @@ namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/**
|
||||
* Class $CLASS$
|
||||
* @package $NAMESPACE$
|
||||
* Register the routes required for your module here
|
||||
*/
|
||||
class $CLASS$ extends ServiceProvider
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The root namespace to assume when generating URLs to actions.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rootUrlNamespace = '$MODULE_NAMESPACE$\$MODULE$\Http\Controllers';
|
||||
protected $namespace = '$MODULE_NAMESPACE$\$MODULE$\$CONTROLLER_NAMESPACE$';
|
||||
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
@ -34,12 +34,62 @@ class $CLASS$ extends ServiceProvider
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map(Router $router)
|
||||
{
|
||||
// if (!app()->routesAreCached()) {
|
||||
// require __DIR__ . '$ROUTES_PATH$';
|
||||
// }
|
||||
$this->registerWebRoutes();
|
||||
$this->registerAdminRoutes();
|
||||
$this->registerApiRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function registerWebRoutes(): void
|
||||
{
|
||||
$config = [
|
||||
'as' => '$LOWER_NAME$.',
|
||||
'prefix' => '$LOWER_NAME$',
|
||||
'namespace' => $this->namespace.'\Frontend',
|
||||
'middleware' => ['web'],
|
||||
];
|
||||
|
||||
Route::group($config, function() {
|
||||
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/web.php');
|
||||
});
|
||||
}
|
||||
|
||||
protected function registerAdminRoutes(): void
|
||||
{
|
||||
$config = [
|
||||
'as' => 'admin.$LOWER_NAME$.',
|
||||
'prefix' => 'admin/$LOWER_NAME$',
|
||||
'namespace' => $this->namespace.'\Admin',
|
||||
'middleware' => ['web', 'role:admin'],
|
||||
];
|
||||
|
||||
Route::group($config, function() {
|
||||
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/web.php');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any API routes your module has. Remove this if you aren't using any
|
||||
*/
|
||||
protected function registerApiRoutes(): void
|
||||
{
|
||||
$config = [
|
||||
'as' => 'admin.$LOWER_NAME$.',
|
||||
'prefix' => 'admin/$LOWER_NAME$',
|
||||
'namespace' => $this->namespace.'\Api',
|
||||
'middleware' => ['api'],
|
||||
];
|
||||
|
||||
Route::group($config, function() {
|
||||
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/api.php');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
<?php
|
||||
|
||||
# This is the admin path. Comment this out if you don't have an admin panel component.
|
||||
Route::group([], function () {
|
||||
Route::get('/', 'AdminController@index');
|
||||
});
|
||||
Route::get('/', 'AdminController@index');
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
Route::group(['middleware' => [
|
||||
'role:user' # leave blank to make this public
|
||||
]], function() {
|
||||
# all your routes are prefixed with the above prefix
|
||||
# e.g. yoursite.com/sample
|
||||
Route::get('/', '$STUDLY_NAME$Controller@index');
|
||||
});
|
||||
Route::get('/', '$STUDLY_NAME$Controller@index');
|
||||
|
||||
/*
|
||||
* To register a route that needs to be authentication, wrap it in a
|
||||
* Route::group() with the auth middleware
|
||||
*/
|
||||
// Route::group(['middleware' => 'auth'], function() {
|
||||
// Route::get('/', '$STUDLY_NAME$Controller@index');
|
||||
// })
|
||||
|
@ -1,152 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Route;
|
||||
|
||||
/**
|
||||
* Class $CLASS$
|
||||
* @package $NAMESPACE$
|
||||
*/
|
||||
class $CLASS$ extends ServiceProvider
|
||||
{
|
||||
private $moduleSvc;
|
||||
|
||||
protected $defer = false;
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->moduleSvc = app('App\Services\ModuleService');
|
||||
|
||||
$this->registerRoutes();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
|
||||
$this->registerLinks();
|
||||
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../$MIGRATIONS_PATH$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Add module links here
|
||||
*/
|
||||
public function registerLinks()
|
||||
{
|
||||
// Show this link if logged in
|
||||
// $this->moduleSvc->addFrontendLink('$STUDLY_NAME$', '/$LOWER_NAME$', '', $logged_in=true);
|
||||
|
||||
// Admin links:
|
||||
$this->moduleSvc->addAdminLink('$STUDLY_NAME$', '/admin/$LOWER_NAME$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the routes
|
||||
*/
|
||||
protected function registerRoutes()
|
||||
{
|
||||
/**
|
||||
* Routes for the frontend
|
||||
*/
|
||||
Route::group([
|
||||
'as' => '$LOWER_NAME$.',
|
||||
'prefix' => '$LOWER_NAME$',
|
||||
// If you want a RESTful module, change this to 'api'
|
||||
'middleware' => ['web'],
|
||||
'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers'
|
||||
], function() {
|
||||
$this->loadRoutesFrom(__DIR__ . '/../Http/Routes/web.php');
|
||||
});
|
||||
|
||||
/**
|
||||
* Routes for the admin
|
||||
*/
|
||||
Route::group([
|
||||
'as' => '$LOWER_NAME$.',
|
||||
'prefix' => 'admin/$LOWER_NAME$',
|
||||
// If you want a RESTful module, change this to 'api'
|
||||
'middleware' => ['web', 'role:admin'],
|
||||
'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Admin'
|
||||
], function() {
|
||||
$this->loadRoutesFrom(__DIR__ . '/../Http/Routes/admin.php');
|
||||
});
|
||||
|
||||
/**
|
||||
* Routes for an API
|
||||
*/
|
||||
Route::group([
|
||||
'as' => '$LOWER_NAME$.',
|
||||
'prefix' => 'api/$LOWER_NAME$',
|
||||
// If you want a RESTful module, change this to 'api'
|
||||
'middleware' => ['api'],
|
||||
'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Api'
|
||||
], function() {
|
||||
$this->loadRoutesFrom(__DIR__ . '/../Http/Routes/api.php');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__.'/../$PATH_CONFIG$/config.php' => config_path('$LOWER_NAME$.php'),
|
||||
], '$LOWER_NAME$');
|
||||
|
||||
$this->mergeConfigFrom(
|
||||
__DIR__.'/../$PATH_CONFIG$/config.php', '$LOWER_NAME$'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews()
|
||||
{
|
||||
$viewPath = resource_path('views/modules/$LOWER_NAME$');
|
||||
$sourcePath = __DIR__.'/../$PATH_VIEWS$';
|
||||
|
||||
$this->publishes([
|
||||
$sourcePath => $viewPath
|
||||
],'views');
|
||||
|
||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||
return $path . '/modules/$LOWER_NAME$';
|
||||
}, \Config::get('view.paths')), [$sourcePath]), '$LOWER_NAME$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations()
|
||||
{
|
||||
$langPath = resource_path('lang/modules/$LOWER_NAME$');
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, '$LOWER_NAME$');
|
||||
} else {
|
||||
$this->loadTranslationsFrom(__DIR__ .'/../$PATH_LANG$', '$LOWER_NAME$');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user