This view is loaded from module: {!! config('sample.name') !!}
+diff --git a/modules/Sample/Config/config.php b/modules/Sample/Config/config.php new file mode 100644 index 00000000..36578109 --- /dev/null +++ b/modules/Sample/Config/config.php @@ -0,0 +1,5 @@ + 'Sample' +]; diff --git a/modules/Sample/Database/seeders/SampleDatabaseSeeder.php b/modules/Sample/Database/seeders/SampleDatabaseSeeder.php new file mode 100644 index 00000000..dad32f12 --- /dev/null +++ b/modules/Sample/Database/seeders/SampleDatabaseSeeder.php @@ -0,0 +1,21 @@ +call("OthersTableSeeder"); + } +} diff --git a/modules/Sample/Http/Controllers/AdminController.php b/modules/Sample/Http/Controllers/AdminController.php new file mode 100644 index 00000000..596724f3 --- /dev/null +++ b/modules/Sample/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('/', 'SampleController@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/Sample/Listeners/TestEventListener.php b/modules/Sample/Listeners/TestEventListener.php new file mode 100644 index 00000000..4725fd4b --- /dev/null +++ b/modules/Sample/Listeners/TestEventListener.php @@ -0,0 +1,16 @@ + [TestEventListener::class], + ]; + + /** + * Register any events for your application. + */ + public function boot() + { + parent::boot(); + } +} diff --git a/modules/Sample/Providers/SampleServiceProvider.php b/modules/Sample/Providers/SampleServiceProvider.php new file mode 100644 index 00000000..e0261e3d --- /dev/null +++ b/modules/Sample/Providers/SampleServiceProvider.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('Sample', '/sample', '', $logged_in=true); + + // Admin links: + $this->moduleSvc->addAdminLink('Sample', '/sample/admin'); + } + + /** + * Register the routes + */ + protected function registerRoutes() + { + Route::group([ + 'as' => 'sample.', + 'prefix' => 'sample', + // If you want a RESTful module, change this to 'api' + 'middleware' => ['web'], + 'namespace' => 'Modules\Sample\Http\Controllers' + ], function() { + $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); + }); + } + + /** + * Register config. + */ + protected function registerConfig() + { + $this->publishes([ + __DIR__.'/../Config/config.php' => config_path('sample.php'), + ], 'config'); + + $this->mergeConfigFrom( + __DIR__.'/../Config/config.php', 'sample' + ); + } + + /** + * Register views. + */ + public function registerViews() + { + $viewPath = resource_path('views/modules/sample'); + $sourcePath = __DIR__.'/../Resources/views'; + + $this->publishes([ + $sourcePath => $viewPath + ],'views'); + + $this->loadViewsFrom(array_merge(array_map(function ($path) { + return $path . '/modules/sample'; + }, \Config::get('view.paths')), [$sourcePath]), 'sample'); + } + + /** + * Register translations. + */ + public function registerTranslations() + { + $langPath = resource_path('lang/modules/sample'); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, 'sample'); + } else { + $this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'sample'); + } + } + + /** + * 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/Sample/Resources/views/admin/index.blade.php b/modules/Sample/Resources/views/admin/index.blade.php new file mode 100644 index 00000000..62e588c0 --- /dev/null +++ b/modules/Sample/Resources/views/admin/index.blade.php @@ -0,0 +1,18 @@ +@extends('sample::layouts.admin') + +@section('title', 'Sample') +@section('actions') +
This view is loaded from module: {!! config('sample.name') !!}
++ This view is loaded from module: {!! config('sample.name') !!} +
+@endsection diff --git a/modules/Sample/Resources/views/layouts/admin.blade.php b/modules/Sample/Resources/views/layouts/admin.blade.php new file mode 100644 index 00000000..421bbe11 --- /dev/null +++ b/modules/Sample/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/Sample/Resources/views/layouts/frontend.blade.php b/modules/Sample/Resources/views/layouts/frontend.blade.php new file mode 100644 index 00000000..9340e4f9 --- /dev/null +++ b/modules/Sample/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/Sample/composer.json b/modules/Sample/composer.json new file mode 100644 index 00000000..9b016e64 --- /dev/null +++ b/modules/Sample/composer.json @@ -0,0 +1,31 @@ +{ + "name": "nabeel/sample", + "type": "laravel-module", + "license": "MIT", + "description": "", + "authors": [ + { + "name": "Nabeel Shahzad", + "email": "gm@nabs.io" + } + ], + "require": { + "joshbrw/laravel-module-installer": "dev-master" + }, + "extra": { + "laravel": { + "providers": [ + "Modules\\Sample\\Providers\\SampleServiceProvider", + "Modules\\Sample\\Providers\\EventServiceProvider" + ], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Sample\\": "" + } + } +} diff --git a/modules/Sample/module.json b/modules/Sample/module.json new file mode 100644 index 00000000..7f563f3b --- /dev/null +++ b/modules/Sample/module.json @@ -0,0 +1,15 @@ +{ + "name": "Sample", + "alias": "sample", + "description": "", + "keywords": [], + "active": 1, + "order": 0, + "providers": [ + "Modules\\Sample\\Providers\\SampleServiceProvider", + "Modules\\Sample\\Providers\\EventServiceProvider" + ], + "aliases": {}, + "files": [], + "requires": [] +}