diff --git a/modules/vacentral/Config/config.php b/modules/vacentral/Config/config.php new file mode 100644 index 00000000..05faf7c8 --- /dev/null +++ b/modules/vacentral/Config/config.php @@ -0,0 +1,5 @@ + 'Vacentral' +]; diff --git a/modules/vacentral/Database/seeders/VacentralDatabaseSeeder.php b/modules/vacentral/Database/seeders/VacentralDatabaseSeeder.php new file mode 100644 index 00000000..347803ea --- /dev/null +++ b/modules/vacentral/Database/seeders/VacentralDatabaseSeeder.php @@ -0,0 +1,21 @@ +call("OthersTableSeeder"); + } +} diff --git a/modules/vacentral/Http/Controllers/AdminController.php b/modules/vacentral/Http/Controllers/AdminController.php new file mode 100644 index 00000000..8520efe8 --- /dev/null +++ b/modules/vacentral/Http/Controllers/AdminController.php @@ -0,0 +1,63 @@ + [ + 'role:admin|user' # leave blank to make this public +]], function() { + + # all your routes are prefixed with the above prefix + # e.g. yoursite.com/sample + Route::get('/', 'VacentralController@index'); + + # This is the admin path. Comment this out if you don't have + # an admin panel component. + Route::group([ + 'middleware' => ['role:admin'], + ], function () { + Route::get('/admin', 'AdminController@index'); + }); +}); diff --git a/modules/vacentral/Listeners/TestEventListener.php b/modules/vacentral/Listeners/TestEventListener.php new file mode 100644 index 00000000..a06bbbfb --- /dev/null +++ b/modules/vacentral/Listeners/TestEventListener.php @@ -0,0 +1,16 @@ + [TestEventListener::class], + ]; + + /** + * Register any events for your application. + */ + public function boot() + { + parent::boot(); + } +} diff --git a/modules/vacentral/Providers/VacentralServiceProvider.php b/modules/vacentral/Providers/VacentralServiceProvider.php new file mode 100644 index 00000000..4703a4eb --- /dev/null +++ b/modules/vacentral/Providers/VacentralServiceProvider.php @@ -0,0 +1,132 @@ +moduleSvc = app('App\Services\ModuleService'); + + $this->registerRoutes(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + + $this->registerLinks(); + + $this->registerFactories(); + $this->loadMigrationsFrom(__DIR__ . '/../Database/migrations'); + } + + /** + * Register the service provider. + */ + public function register() + { + // + } + + /** + * Add module links here + */ + public function registerLinks() + { + // Show this link if logged in + // $this->moduleSvc->addFrontendLink('Vacentral', '/vacentral', '', $logged_in=true); + + // Admin links: + $this->moduleSvc->addAdminLink('Vacentral', '/vacentral/admin'); + } + + /** + * Register the routes + */ + protected function registerRoutes() + { + Route::group([ + 'as' => 'vacentral.', + 'prefix' => 'vacentral', + // If you want a RESTful module, change this to 'api' + 'middleware' => ['web'], + 'namespace' => 'Modules\Vacentral\Http\Controllers' + ], function() { + $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); + }); + } + + /** + * Register config. + */ + protected function registerConfig() + { + $this->publishes([ + __DIR__.'/../Config/config.php' => config_path('vacentral.php'), + ], 'config'); + + $this->mergeConfigFrom( + __DIR__.'/../Config/config.php', 'vacentral' + ); + } + + /** + * Register views. + */ + public function registerViews() + { + $viewPath = resource_path('views/modules/vacentral'); + $sourcePath = __DIR__.'/../Resources/views'; + + $this->publishes([ + $sourcePath => $viewPath + ],'views'); + + $this->loadViewsFrom(array_merge(array_map(function ($path) { + return $path . '/modules/vacentral'; + }, \Config::get('view.paths')), [$sourcePath]), 'vacentral'); + } + + /** + * Register translations. + */ + public function registerTranslations() + { + $langPath = resource_path('lang/modules/vacentral'); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, 'vacentral'); + } else { + $this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'vacentral'); + } + } + + /** + * Register an additional directory of factories. + * @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66 + */ + public function registerFactories() + { + if (! app()->environment('production')) { + app(Factory::class)->load(__DIR__ . '/../Database/factories'); + } + } + + /** + * Get the services provided by the provider. + */ + public function provides() + { + return []; + } +} diff --git a/modules/vacentral/Resources/views/admin/index.blade.php b/modules/vacentral/Resources/views/admin/index.blade.php new file mode 100644 index 00000000..520940fd --- /dev/null +++ b/modules/vacentral/Resources/views/admin/index.blade.php @@ -0,0 +1,18 @@ +@extends('vacentral::layouts.admin') + +@section('title', 'Vacentral') +@section('actions') +
  • + + + Add New +
  • +@endsection +@section('content') +
    +

    Admin Scaffold!

    +
    +

    This view is loaded from module: {!! config('vacentral.name') !!}

    +
    +
    +@endsection diff --git a/modules/vacentral/Resources/views/index.blade.php b/modules/vacentral/Resources/views/index.blade.php new file mode 100644 index 00000000..ec38cd46 --- /dev/null +++ b/modules/vacentral/Resources/views/index.blade.php @@ -0,0 +1,9 @@ +@extends('vacentral::layouts.frontend') + +@section('content') +

    Hello World

    + +

    + This view is loaded from module: {!! config('vacentral.name') !!} +

    +@endsection diff --git a/modules/vacentral/Resources/views/layouts/admin.blade.php b/modules/vacentral/Resources/views/layouts/admin.blade.php new file mode 100644 index 00000000..421bbe11 --- /dev/null +++ b/modules/vacentral/Resources/views/layouts/admin.blade.php @@ -0,0 +1,5 @@ +{{-- +You probably don't want to edit anything here. Just make +sure to extend this in your views. It will pass the content section through +--}} +@extends('admin.app') diff --git a/modules/vacentral/Resources/views/layouts/frontend.blade.php b/modules/vacentral/Resources/views/layouts/frontend.blade.php new file mode 100644 index 00000000..9340e4f9 --- /dev/null +++ b/modules/vacentral/Resources/views/layouts/frontend.blade.php @@ -0,0 +1,5 @@ +{{-- +You probably don't want to edit anything here. Just make +sure to extend this in your views. It will pass the content section through +--}} +@extends('layouts.' . config('phpvms.skin') . '.app') diff --git a/modules/vacentral/composer.json b/modules/vacentral/composer.json new file mode 100644 index 00000000..e9a22256 --- /dev/null +++ b/modules/vacentral/composer.json @@ -0,0 +1,26 @@ +{ + "name": "/vacentral", + "description": "", + "authors": [ + { + "name": "", + "email": "" + } + ], + "extra": { + "laravel": { + "providers": [ + "Modules\\Vacentral\\Providers\\VacentralServiceProvider", + "Modules\\Vacentral\\Providers\\EventServiceProvider" + ], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Vacentral\\": "" + } + } +} diff --git a/modules/vacentral/module.json b/modules/vacentral/module.json new file mode 100644 index 00000000..8c333e0b --- /dev/null +++ b/modules/vacentral/module.json @@ -0,0 +1,15 @@ +{ + "name": "Vacentral", + "alias": "vacentral", + "description": "", + "keywords": [], + "active": 1, + "order": 0, + "providers": [ + "Modules\\Vacentral\\Providers\\VacentralServiceProvider", + "Modules\\Vacentral\\Providers\\EventServiceProvider" + ], + "aliases": {}, + "files": [], + "requires": [] +}