* 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
|
# Matches the exact files either package.json or .travis.yml
|
||||||
[{package.json, .travis.yml}]
|
[{package.json, .travis.yml}]
|
||||||
indent_style = space
|
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/frontend' => 'Resources/views/layouts/frontend.blade.php',
|
||||||
'views/admin' => 'Resources/views/layouts/admin.blade.php',
|
'views/admin' => 'Resources/views/layouts/admin.blade.php',
|
||||||
'listener-test' => 'Listeners/TestEventListener.php',
|
'listener-test' => 'Listeners/TestEventListener.php',
|
||||||
|
'controller-index' => 'Http/Controllers/Frontend/IndexController.php',
|
||||||
'controller-api' => 'Http/Controllers/Api/ApiController.php',
|
'controller-api' => 'Http/Controllers/Api/ApiController.php',
|
||||||
'controller-admin' => 'Http/Controllers/Admin/AdminController.php',
|
'controller-admin' => 'Http/Controllers/Admin/AdminController.php',
|
||||||
'scaffold/config' => 'Config/config.php',
|
'config' => 'Config/config.php',
|
||||||
'composer' => 'composer.json',
|
'composer' => 'composer.json',
|
||||||
],
|
],
|
||||||
'replacements' => [
|
'replacements' => [
|
||||||
@ -27,22 +28,45 @@ return [
|
|||||||
'routes' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
'routes' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||||
'routes-api' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
'routes-api' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||||
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||||
'event-service-provider' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
'provider' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||||
'listener-test' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
'event-service-provider' => [
|
||||||
'views/index' => ['LOWER_NAME'],
|
'LOWER_NAME',
|
||||||
'views/index-admin' => ['LOWER_NAME', 'STUDLY_NAME'],
|
'STUDLY_NAME',
|
||||||
'views/frontend' => ['STUDLY_NAME'],
|
'MODULE_NAMESPACE',
|
||||||
'views/admin' => ['STUDLY_NAME'],
|
'CLASS_NAMESPACE',
|
||||||
'controller-admin' => ['MODULE_NAMESPACE', 'STUDLY_NAME', 'CLASS_NAMESPACE', 'LOWER_NAME'],
|
],
|
||||||
'controller-api' => ['MODULE_NAMESPACE', 'STUDLY_NAME', 'CLASS_NAMESPACE', 'LOWER_NAME'],
|
'listener-test' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE'],
|
||||||
'scaffold/config' => ['STUDLY_NAME'],
|
'views/index' => ['LOWER_NAME'],
|
||||||
'composer' => [
|
'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',
|
'LOWER_NAME',
|
||||||
'STUDLY_NAME',
|
'STUDLY_NAME',
|
||||||
'VENDOR',
|
'VENDOR',
|
||||||
'AUTHOR_NAME',
|
'AUTHOR_NAME',
|
||||||
'AUTHOR_EMAIL',
|
'AUTHOR_EMAIL',
|
||||||
'MODULE_NAMESPACE',
|
'MODULE_NAMESPACE',
|
||||||
|
'PROVIDER_NAMESPACE',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'gitkeep' => false,
|
'gitkeep' => false,
|
||||||
@ -52,15 +76,16 @@ return [
|
|||||||
'assets' => public_path('modules'),
|
'assets' => public_path('modules'),
|
||||||
'migration' => base_path('database/migrations'),
|
'migration' => base_path('database/migrations'),
|
||||||
'generator' => [
|
'generator' => [
|
||||||
'config' => ['path' => 'Config', 'generate' => true],
|
'config' => ['path' => 'Config', 'generate' => true],
|
||||||
'command' => ['path' => 'Console', 'generate' => true],
|
'command' => ['path' => 'Console', 'generate' => true],
|
||||||
'migration' => ['path' => 'Database/migrations', 'generate' => true],
|
'migration' => ['path' => 'Database/migrations', 'generate' => true],
|
||||||
'seeds' => ['path' => 'Database/seeds', 'generate' => true],
|
'seeds' => ['path' => 'Database/seeds', 'generate' => true],
|
||||||
'factory' => ['path' => 'Database/factories', 'generate' => true],
|
'factory' => ['path' => 'Database/factories', 'generate' => true],
|
||||||
'model' => ['path' => 'Models', 'generate' => true],
|
'model' => ['path' => 'Models', 'generate' => true],
|
||||||
'controller' => ['path' => 'Http/Controllers', 'generate' => true],
|
//'controller' => ['path' => 'Http/Controllers', 'generate' => true],
|
||||||
'controller-admin' => ['path' => 'Http/Controllers/Admin', 'generate' => true],
|
'controller-admin' => ['path' => 'Http/Controllers/Admin', 'generate' => true],
|
||||||
'controller-api' => ['path' => 'Http/Controllers/Api', 'generate' => true],
|
'controller-api' => ['path' => 'Http/Controllers/Api', 'generate' => true],
|
||||||
|
'controller-index' => ['path' => 'Http/Controllers/Frontend', 'generate' => true],
|
||||||
'filter' => ['path' => 'Http/Middleware', 'generate' => true],
|
'filter' => ['path' => 'Http/Middleware', 'generate' => true],
|
||||||
'request' => ['path' => 'Http/Requests', 'generate' => true],
|
'request' => ['path' => 'Http/Requests', 'generate' => true],
|
||||||
'routes' => ['path' => 'Http/Routes', 'generate' => true],
|
'routes' => ['path' => 'Http/Routes', 'generate' => true],
|
||||||
@ -124,7 +149,7 @@ return [
|
|||||||
'cache' => [
|
'cache' => [
|
||||||
'enabled' => true,
|
'enabled' => true,
|
||||||
'key' => 'phpvms-modules',
|
'key' => 'phpvms-modules',
|
||||||
'lifetime' => 10,
|
'lifetime' => 0,
|
||||||
],
|
],
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@ -143,7 +168,7 @@ return [
|
|||||||
'class' => FileActivator::class,
|
'class' => FileActivator::class,
|
||||||
'statuses-file' => config_path('modules_statuses.json'),
|
'statuses-file' => config_path('modules_statuses.json'),
|
||||||
'cache-key' => 'activator.installed',
|
'cache-key' => 'activator.installed',
|
||||||
'cache-lifetime' => 604800,
|
'cache-lifetime' => 0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -5,5 +5,6 @@
|
|||||||
"Sample": true,
|
"Sample": true,
|
||||||
"Updater": true,
|
"Updater": true,
|
||||||
"VMSAcars": true,
|
"VMSAcars": true,
|
||||||
"Vacentral": true
|
"Vacentral": true,
|
||||||
}
|
"TestModule": true
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Modules\Awards\Providers;
|
namespace Modules\Awards\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use App\Contracts\Modules\ServiceProvider;
|
||||||
|
|
||||||
class AwardServiceProvider extends ServiceProvider
|
class AwardServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace Modules\Importer\Providers;
|
namespace Modules\Importer\Providers;
|
||||||
|
|
||||||
|
use App\Contracts\Modules\ServiceProvider;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\ServiceProvider;
|
|
||||||
use Modules\Importer\Console\Commands\ImportFromClassicCommand;
|
use Modules\Importer\Console\Commands\ImportFromClassicCommand;
|
||||||
|
|
||||||
class ImporterServiceProvider extends ServiceProvider
|
class ImporterServiceProvider extends ServiceProvider
|
||||||
@ -11,7 +11,7 @@ class ImporterServiceProvider extends ServiceProvider
|
|||||||
/**
|
/**
|
||||||
* Boot the application events.
|
* Boot the application events.
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot(): void
|
||||||
{
|
{
|
||||||
$this->registerCommands();
|
$this->registerCommands();
|
||||||
$this->registerRoutes();
|
$this->registerRoutes();
|
||||||
@ -20,6 +20,9 @@ class ImporterServiceProvider extends ServiceProvider
|
|||||||
$this->registerViews();
|
$this->registerViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register console commands
|
||||||
|
*/
|
||||||
protected function registerCommands()
|
protected function registerCommands()
|
||||||
{
|
{
|
||||||
$this->commands([
|
$this->commands([
|
||||||
@ -44,7 +47,6 @@ class ImporterServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
// Run the actual importer process. Additional middleware
|
// Run the actual importer process. Additional middleware
|
||||||
Route::post('/run', 'ImporterController@run')->middleware('api')->name('run');
|
Route::post('/run', 'ImporterController@run')->middleware('api')->name('run');
|
||||||
|
|
||||||
Route::post('/complete', 'ImporterController@complete')->name('complete');
|
Route::post('/complete', 'ImporterController@complete')->name('complete');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -91,12 +93,4 @@ class ImporterServiceProvider extends ServiceProvider
|
|||||||
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'importer');
|
$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;
|
namespace Modules\Installer\Providers;
|
||||||
|
|
||||||
|
use App\Contracts\Modules\ServiceProvider;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\ServiceProvider;
|
|
||||||
|
|
||||||
class InstallerServiceProvider extends ServiceProvider
|
class InstallerServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Boot the application events.
|
* Boot the application events.
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot(): void
|
||||||
{
|
{
|
||||||
$this->registerRoutes();
|
$this->registerRoutes();
|
||||||
$this->registerTranslations();
|
$this->registerTranslations();
|
||||||
|
@ -14,8 +14,9 @@
|
|||||||
"extra": {
|
"extra": {
|
||||||
"laravel": {
|
"laravel": {
|
||||||
"providers": [
|
"providers": [
|
||||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\$STUDLY_NAME$ServiceProvider",
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\AppServiceProvider",
|
||||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\EventServiceProvider"
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\EventServiceProvider",
|
||||||
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\RouteServiceProvider"
|
||||||
],
|
],
|
||||||
"aliases": {
|
"aliases": {
|
||||||
|
|
||||||
|
@ -6,52 +6,71 @@ use App\Contracts\Controller;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AdminController
|
* Admin controller
|
||||||
* @package $MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Admin
|
|
||||||
*/
|
*/
|
||||||
class AdminController extends Controller
|
class AdminController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* 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');
|
return view('$LOWER_NAME$::admin.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* 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');
|
return view('$LOWER_NAME$::admin.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
*/
|
*/
|
||||||
public function store(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.
|
* 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');
|
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.
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
*/
|
*/
|
||||||
public function update(Request $request)
|
public function update(Request $request)
|
||||||
{
|
{
|
||||||
@ -59,8 +78,10 @@ class AdminController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the specified resource from storage.
|
* 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
|
* Just send out a message
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
@ -23,7 +25,9 @@ class ApiController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles /hello
|
* Handles /hello
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function hello(Request $request)
|
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
|
<?php
|
||||||
|
|
||||||
namespace $CLASS_NAMESPACE$;
|
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers\Frontend;
|
||||||
|
|
||||||
use App\Contracts\Controller;
|
use App\Contracts\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@ -13,23 +13,34 @@ class $CLASS$ extends Controller
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
return view('$LOWER_NAME$::index');
|
return view('$LOWER_NAME$::index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* 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');
|
return view('$LOWER_NAME$::create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
* @param Request $request
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
@ -37,22 +48,32 @@ class $CLASS$ extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the specified resource.
|
* Show the specified resource.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function show()
|
public function show(Request $request)
|
||||||
{
|
{
|
||||||
return view('$LOWER_NAME$::show');
|
return view('$LOWER_NAME$::show');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* 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');
|
return view('$LOWER_NAME$::edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
*/
|
*/
|
||||||
public function update(Request $request)
|
public function update(Request $request)
|
||||||
{
|
{
|
||||||
@ -60,8 +81,10 @@ class $CLASS$ extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
*/
|
*/
|
||||||
public function destroy()
|
public function destroy(Request $request)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
"active": 1,
|
"active": 1,
|
||||||
"order": 0,
|
"order": 0,
|
||||||
"providers": [
|
"providers": [
|
||||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\$STUDLY_NAME$ServiceProvider",
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\AppServiceProvider",
|
||||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\EventServiceProvider"
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\EventServiceProvider",
|
||||||
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\RouteServiceProvider"
|
||||||
],
|
],
|
||||||
"aliases": {},
|
"aliases": {},
|
||||||
"files": [],
|
"files": [],
|
||||||
|
@ -3,12 +3,17 @@
|
|||||||
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Listeners;
|
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Listeners;
|
||||||
|
|
||||||
use App\Events\TestEvent;
|
use App\Events\TestEvent;
|
||||||
use Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A sample event listener
|
||||||
|
*/
|
||||||
class TestEventListener
|
class TestEventListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param \App\Events\TestEvent $event
|
||||||
*/
|
*/
|
||||||
public function handle(TestEvent $event) {
|
public function handle(TestEvent $event) {
|
||||||
Log::info('Received event', [$event]);
|
Log::info('Received event', [$event]);
|
||||||
|
@ -1,26 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace $NAMESPACE$;
|
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use App\Contracts\Modules\ServiceProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class $CLASS$
|
|
||||||
* @package $NAMESPACE$
|
* @package $NAMESPACE$
|
||||||
*/
|
*/
|
||||||
class $CLASS$ extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
private $moduleSvc;
|
||||||
* Indicates if loading of the provider is deferred.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $defer = false;
|
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.
|
* Register the service provider.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
@ -28,12 +39,55 @@ class $CLASS$ extends ServiceProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the services provided by the provider.
|
* Add module links here
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
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\Routing\Router;
|
||||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class $CLASS$
|
* Register the routes required for your module here
|
||||||
* @package $NAMESPACE$
|
|
||||||
*/
|
*/
|
||||||
class $CLASS$ extends ServiceProvider
|
class RouteServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The root namespace to assume when generating URLs to actions.
|
* The root namespace to assume when generating URLs to actions.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $rootUrlNamespace = '$MODULE_NAMESPACE$\$MODULE$\Http\Controllers';
|
protected $namespace = '$MODULE_NAMESPACE$\$MODULE$\$CONTROLLER_NAMESPACE$';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before routes are registered.
|
* Called before routes are registered.
|
||||||
@ -34,12 +34,62 @@ class $CLASS$ extends ServiceProvider
|
|||||||
/**
|
/**
|
||||||
* Define the routes for the application.
|
* Define the routes for the application.
|
||||||
*
|
*
|
||||||
|
* @param \Illuminate\Routing\Router $router
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function map(Router $router)
|
public function map(Router $router)
|
||||||
{
|
{
|
||||||
// if (!app()->routesAreCached()) {
|
$this->registerWebRoutes();
|
||||||
// require __DIR__ . '$ROUTES_PATH$';
|
$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
|
<?php
|
||||||
|
|
||||||
# This is the admin path. Comment this out if you don't have an admin panel component.
|
# 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
|
<?php
|
||||||
|
|
||||||
Route::group(['middleware' => [
|
Route::get('/', '$STUDLY_NAME$Controller@index');
|
||||||
'role:user' # leave blank to make this public
|
|
||||||
]], function() {
|
/*
|
||||||
# all your routes are prefixed with the above prefix
|
* To register a route that needs to be authentication, wrap it in a
|
||||||
# e.g. yoursite.com/sample
|
* Route::group() with the auth middleware
|
||||||
Route::get('/', '$STUDLY_NAME$Controller@index');
|
*/
|
||||||
});
|
// 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