From 3f0d9a420b7dcf502369f1d088ab5bac852c8031 Mon Sep 17 00:00:00 2001 From: Ranjan Date: Tue, 16 Apr 2024 11:38:27 +0545 Subject: [PATCH] pms module setup --- Modules/PMS/app/Http/Controllers/.gitkeep | 0 .../app/Http/Controllers/PMSController.php | 67 ++++++++++ Modules/PMS/app/Http/Requests/.gitkeep | 0 Modules/PMS/app/Models/.gitkeep | 0 Modules/PMS/app/Observers/.gitkeep | 0 Modules/PMS/app/Providers/.gitkeep | 0 .../PMS/app/Providers/PMSServiceProvider.php | 114 ++++++++++++++++++ .../app/Providers/RouteServiceProvider.php | 49 ++++++++ Modules/PMS/app/Repositories/.gitkeep | 0 Modules/PMS/composer.json | 30 +++++ Modules/PMS/config/.gitkeep | 0 Modules/PMS/config/config.php | 5 + Modules/PMS/database/factories/.gitkeep | 0 Modules/PMS/database/migrations/.gitkeep | 0 Modules/PMS/database/seeders/.gitkeep | 0 .../database/seeders/PMSDatabaseSeeder.php | 16 +++ Modules/PMS/module.json | 11 ++ Modules/PMS/package.json | 15 +++ Modules/PMS/resources/assets/.gitkeep | 0 Modules/PMS/resources/assets/js/app.js | 0 Modules/PMS/resources/assets/sass/app.scss | 0 Modules/PMS/resources/views/.gitkeep | 0 Modules/PMS/resources/views/index.blade.php | 7 ++ .../resources/views/layouts/master.blade.php | 29 +++++ Modules/PMS/routes/.gitkeep | 0 Modules/PMS/routes/api.php | 19 +++ Modules/PMS/routes/web.php | 19 +++ Modules/PMS/vite.config.js | 26 ++++ modules_statuses.json | 3 +- .../views/layouts/partials/sidebar.blade.php | 99 ++++++++------- 30 files changed, 456 insertions(+), 53 deletions(-) create mode 100644 Modules/PMS/app/Http/Controllers/.gitkeep create mode 100644 Modules/PMS/app/Http/Controllers/PMSController.php create mode 100644 Modules/PMS/app/Http/Requests/.gitkeep create mode 100644 Modules/PMS/app/Models/.gitkeep create mode 100644 Modules/PMS/app/Observers/.gitkeep create mode 100644 Modules/PMS/app/Providers/.gitkeep create mode 100644 Modules/PMS/app/Providers/PMSServiceProvider.php create mode 100644 Modules/PMS/app/Providers/RouteServiceProvider.php create mode 100644 Modules/PMS/app/Repositories/.gitkeep create mode 100644 Modules/PMS/composer.json create mode 100644 Modules/PMS/config/.gitkeep create mode 100644 Modules/PMS/config/config.php create mode 100644 Modules/PMS/database/factories/.gitkeep create mode 100644 Modules/PMS/database/migrations/.gitkeep create mode 100644 Modules/PMS/database/seeders/.gitkeep create mode 100644 Modules/PMS/database/seeders/PMSDatabaseSeeder.php create mode 100644 Modules/PMS/module.json create mode 100644 Modules/PMS/package.json create mode 100644 Modules/PMS/resources/assets/.gitkeep create mode 100644 Modules/PMS/resources/assets/js/app.js create mode 100644 Modules/PMS/resources/assets/sass/app.scss create mode 100644 Modules/PMS/resources/views/.gitkeep create mode 100644 Modules/PMS/resources/views/index.blade.php create mode 100644 Modules/PMS/resources/views/layouts/master.blade.php create mode 100644 Modules/PMS/routes/.gitkeep create mode 100644 Modules/PMS/routes/api.php create mode 100644 Modules/PMS/routes/web.php create mode 100644 Modules/PMS/vite.config.js diff --git a/Modules/PMS/app/Http/Controllers/.gitkeep b/Modules/PMS/app/Http/Controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/app/Http/Controllers/PMSController.php b/Modules/PMS/app/Http/Controllers/PMSController.php new file mode 100644 index 0000000..35aaf6f --- /dev/null +++ b/Modules/PMS/app/Http/Controllers/PMSController.php @@ -0,0 +1,67 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $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. + */ + public function registerViews(): void + { + $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); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder',''))); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/Modules/PMS/app/Providers/RouteServiceProvider.php b/Modules/PMS/app/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..bb7b2bc --- /dev/null +++ b/Modules/PMS/app/Providers/RouteServiceProvider.php @@ -0,0 +1,49 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web')->group(module_path('PMS', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::middleware('api')->prefix('api')->name('api.')->group(module_path('PMS', '/routes/api.php')); + } +} diff --git a/Modules/PMS/app/Repositories/.gitkeep b/Modules/PMS/app/Repositories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/composer.json b/Modules/PMS/composer.json new file mode 100644 index 0000000..6d1bd08 --- /dev/null +++ b/Modules/PMS/composer.json @@ -0,0 +1,30 @@ +{ + "name": "nwidart/pms", + "description": "", + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\PMS\\": "app/", + "Modules\\PMS\\Database\\Factories\\": "database/factories/", + "Modules\\PMS\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\PMS\\Tests\\": "tests/" + } + } +} diff --git a/Modules/PMS/config/.gitkeep b/Modules/PMS/config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/config/config.php b/Modules/PMS/config/config.php new file mode 100644 index 0000000..de95922 --- /dev/null +++ b/Modules/PMS/config/config.php @@ -0,0 +1,5 @@ + 'PMS', +]; diff --git a/Modules/PMS/database/factories/.gitkeep b/Modules/PMS/database/factories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/database/migrations/.gitkeep b/Modules/PMS/database/migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/database/seeders/.gitkeep b/Modules/PMS/database/seeders/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/database/seeders/PMSDatabaseSeeder.php b/Modules/PMS/database/seeders/PMSDatabaseSeeder.php new file mode 100644 index 0000000..2687b20 --- /dev/null +++ b/Modules/PMS/database/seeders/PMSDatabaseSeeder.php @@ -0,0 +1,16 @@ +call([]); + } +} diff --git a/Modules/PMS/module.json b/Modules/PMS/module.json new file mode 100644 index 0000000..f220122 --- /dev/null +++ b/Modules/PMS/module.json @@ -0,0 +1,11 @@ +{ + "name": "PMS", + "alias": "pms", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\PMS\\Providers\\PMSServiceProvider" + ], + "files": [] +} diff --git a/Modules/PMS/package.json b/Modules/PMS/package.json new file mode 100644 index 0000000..d6fbfc8 --- /dev/null +++ b/Modules/PMS/package.json @@ -0,0 +1,15 @@ +{ + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build" + }, + "devDependencies": { + "axios": "^1.1.2", + "laravel-vite-plugin": "^0.7.5", + "sass": "^1.69.5", + "postcss": "^8.3.7", + "vite": "^4.0.0" + } +} diff --git a/Modules/PMS/resources/assets/.gitkeep b/Modules/PMS/resources/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/resources/assets/js/app.js b/Modules/PMS/resources/assets/js/app.js new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/resources/assets/sass/app.scss b/Modules/PMS/resources/assets/sass/app.scss new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/resources/views/.gitkeep b/Modules/PMS/resources/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/resources/views/index.blade.php b/Modules/PMS/resources/views/index.blade.php new file mode 100644 index 0000000..d3844ce --- /dev/null +++ b/Modules/PMS/resources/views/index.blade.php @@ -0,0 +1,7 @@ +@extends('pms::layouts.master') + +@section('content') +

Hello World

+ +

Module: {!! config('pms.name') !!}

+@endsection diff --git a/Modules/PMS/resources/views/layouts/master.blade.php b/Modules/PMS/resources/views/layouts/master.blade.php new file mode 100644 index 0000000..4cb13c1 --- /dev/null +++ b/Modules/PMS/resources/views/layouts/master.blade.php @@ -0,0 +1,29 @@ + + + + + + + + + + PMS Module - {{ config('app.name', 'Laravel') }} + + + + + + + + + + {{-- Vite CSS --}} + {{-- {{ module_vite('build-pms', 'resources/assets/sass/app.scss') }} --}} + + + + @yield('content') + + {{-- Vite JS --}} + {{-- {{ module_vite('build-pms', 'resources/assets/js/app.js') }} --}} + diff --git a/Modules/PMS/routes/.gitkeep b/Modules/PMS/routes/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/PMS/routes/api.php b/Modules/PMS/routes/api.php new file mode 100644 index 0000000..2e3b635 --- /dev/null +++ b/Modules/PMS/routes/api.php @@ -0,0 +1,19 @@ +prefix('v1')->group(function () { + Route::apiResource('pms', PMSController::class)->names('pms'); +}); diff --git a/Modules/PMS/routes/web.php b/Modules/PMS/routes/web.php new file mode 100644 index 0000000..02b1588 --- /dev/null +++ b/Modules/PMS/routes/web.php @@ -0,0 +1,19 @@ +names('pms'); +}); diff --git a/Modules/PMS/vite.config.js b/Modules/PMS/vite.config.js new file mode 100644 index 0000000..4ed6e13 --- /dev/null +++ b/Modules/PMS/vite.config.js @@ -0,0 +1,26 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + build: { + outDir: '../../public/build-pms', + emptyOutDir: true, + manifest: true, + }, + plugins: [ + laravel({ + publicDirectory: '../../public', + buildDirectory: 'build-pms', + input: [ + __dirname + '/resources/assets/sass/app.scss', + __dirname + '/resources/assets/js/app.js' + ], + refresh: true, + }), + ], +}); + +//export const paths = [ +// 'Modules/PMS/resources/assets/sass/app.scss', +// 'Modules/PMS/resources/assets/js/app.js', +//]; \ No newline at end of file diff --git a/modules_statuses.json b/modules_statuses.json index a4a5c28..c2503cc 100644 --- a/modules_statuses.json +++ b/modules_statuses.json @@ -4,5 +4,6 @@ "Attendance": true, "User": true, "Admin": true, - "Taxation": true + "Taxation": true, + "PMS": true } \ No newline at end of file diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index e8fc7b2..d33c922 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -34,7 +34,34 @@ Dashboard + + + + {{-- - - + --}} - + {{-- --}} - - - - + --}} {{-- --}} + + +