diff --git a/Modules/Leave/Http/Controllers/.gitkeep b/Modules/Leave/Http/Controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/Http/Controllers/LeaveController.php b/Modules/Leave/Http/Controllers/LeaveController.php new file mode 100644 index 0000000..11913b7 --- /dev/null +++ b/Modules/Leave/Http/Controllers/LeaveController.php @@ -0,0 +1,76 @@ +leaveRepository = $leaveRepository; + } + + /** + * Display a listing of the resource. + */ + public function index() + { + $data['leaves'] = $this->leaveRepository->findAll(); + return view('leave::index'); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + $data['title'] = 'Create Leave'; + return view('leave::create', $data); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request): RedirectResponse + { + dd($request->all()); + } + + /** + * Show the specified resource. + */ + public function show($id) + { + return view('leave::show'); + } + + /** + * Show the form for editing the specified resource. + */ + public function edit($id) + { + return view('leave::edit'); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id): RedirectResponse + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy($id) + { + // + } +} diff --git a/Modules/Leave/Models/.gitkeep b/Modules/Leave/Models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/Models/Leave.php b/Modules/Leave/Models/Leave.php new file mode 100644 index 0000000..64d02eb --- /dev/null +++ b/Modules/Leave/Models/Leave.php @@ -0,0 +1,22 @@ +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/Leave/Providers/RouteServiceProvider.php b/Modules/Leave/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..29b900e --- /dev/null +++ b/Modules/Leave/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('Leave', '/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('Leave', '/routes/api.php')); + } +} diff --git a/Modules/Leave/Repositories/.gitkeep b/Modules/Leave/Repositories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/Repositories/LeaveInterface.php b/Modules/Leave/Repositories/LeaveInterface.php new file mode 100644 index 0000000..d34795e --- /dev/null +++ b/Modules/Leave/Repositories/LeaveInterface.php @@ -0,0 +1,12 @@ +update($newDetails); + } + +} diff --git a/Modules/Leave/composer.json b/Modules/Leave/composer.json new file mode 100644 index 0000000..c2a47e6 --- /dev/null +++ b/Modules/Leave/composer.json @@ -0,0 +1,30 @@ +{ + "name": "nwidart/leave", + "description": "", + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Leave\\": "app/", + "Modules\\Leave\\Database\\Factories\\": "database/factories/", + "Modules\\Leave\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\Leave\\Tests\\": "tests/" + } + } +} diff --git a/Modules/Leave/config/.gitkeep b/Modules/Leave/config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/config/config.php b/Modules/Leave/config/config.php new file mode 100644 index 0000000..827548c --- /dev/null +++ b/Modules/Leave/config/config.php @@ -0,0 +1,5 @@ + 'Leave', +]; diff --git a/Modules/Leave/database/migrations/.gitkeep b/Modules/Leave/database/migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/database/migrations/2024_04_04_102430_create_leaves_table.php b/Modules/Leave/database/migrations/2024_04_04_102430_create_leaves_table.php new file mode 100644 index 0000000..29e656a --- /dev/null +++ b/Modules/Leave/database/migrations/2024_04_04_102430_create_leaves_table.php @@ -0,0 +1,28 @@ +id(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('leaves'); + } +}; diff --git a/Modules/Leave/database/seeders/.gitkeep b/Modules/Leave/database/seeders/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/database/seeders/LeaveDatabaseSeeder.php b/Modules/Leave/database/seeders/LeaveDatabaseSeeder.php new file mode 100644 index 0000000..0a3661a --- /dev/null +++ b/Modules/Leave/database/seeders/LeaveDatabaseSeeder.php @@ -0,0 +1,16 @@ +call([]); + } +} diff --git a/Modules/Leave/module.json b/Modules/Leave/module.json new file mode 100644 index 0000000..c81af7a --- /dev/null +++ b/Modules/Leave/module.json @@ -0,0 +1,11 @@ +{ + "name": "Leave", + "alias": "leave", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Leave\\Providers\\LeaveServiceProvider" + ], + "files": [] +} diff --git a/Modules/Leave/package.json b/Modules/Leave/package.json new file mode 100644 index 0000000..d6fbfc8 --- /dev/null +++ b/Modules/Leave/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/Leave/resources/assets/.gitkeep b/Modules/Leave/resources/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/resources/assets/js/app.js b/Modules/Leave/resources/assets/js/app.js new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/resources/assets/sass/app.scss b/Modules/Leave/resources/assets/sass/app.scss new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/resources/views/.gitkeep b/Modules/Leave/resources/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/resources/views/create.blade.php b/Modules/Leave/resources/views/create.blade.php new file mode 100644 index 0000000..c1393bb --- /dev/null +++ b/Modules/Leave/resources/views/create.blade.php @@ -0,0 +1,39 @@ +@extends('layouts.app') + +@section('content') +
+
+ +
+
+
+

{{ $title }}

+ +
+ +
+ +
+
+
+ +
+
+
+
+
+ @include('leave::partials.action') +
+
+
+
+
+ + +
+ +
+@endsection diff --git a/Modules/Leave/resources/views/index.blade.php b/Modules/Leave/resources/views/index.blade.php new file mode 100644 index 0000000..82f6cc4 --- /dev/null +++ b/Modules/Leave/resources/views/index.blade.php @@ -0,0 +1,298 @@ +@extends('layouts.app') + +@section('content') +
+
+ + {{--
+
+
+

Projects

+ +
+ +
+ +
+
+
--}} + + + {{--
+
+
+
+ +
+
+
+ + +
+
+
+
+
--}} + +
+
+
+
+
Leave Lists
+
+ Add +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NamePositionOfficeAgeStart dateSalary
Tiger NixonSystem ArchitectEdinburgh612011/04/25$320,800
Garrett WintersAccountantTokyo632011/07/25$170,750
Ashton CoxJunior Technical AuthorSan Francisco662009/01/12$86,000
Cedric KellySenior Javascript DeveloperEdinburgh222012/03/29$433,060
Airi SatouAccountantTokyo332008/11/28$162,700
Brielle WilliamsonIntegration SpecialistNew York612012/12/02$372,000
Herrod ChandlerSales AssistantSan Francisco592012/08/06$137,500
Rhona DavidsonIntegration SpecialistTokyo552010/10/14$327,900
Colleen HurstJavascript DeveloperSan Francisco392009/09/15$205,500
Sonya FrostSoftware EngineerEdinburgh232008/12/13$103,600
Jena GainesOffice ManagerLondon302008/12/19$90,560
Quinn FlynnSupport LeadEdinburgh222013/03/03$342,000
Charde MarshallRegional DirectorSan Francisco362008/10/16$470,600
Haley KennedySenior Marketing DesignerLondon432012/12/18$313,500
Tatyana FitzpatrickRegional DirectorLondon192010/03/17$385,750
Michael SilvaMarketing DesignerLondon662012/11/27$198,500
Paul ByrdChief Financial Officer (CFO)New York642010/06/09$725,000
Gloria LittleSystems AdministratorNew York592009/04/10$237,500
Bradley GreerSoftware EngineerLondon412012/10/13$132,000
Dai RiosPersonnel LeadEdinburgh352012/09/26$217,500
Jenette CaldwellDevelopment LeadNew York302011/09/03$345,000
Yuri BerryChief Marketing Officer (CMO)New York402009/06/25$675,000
Caesar VancePre-Sales SupportNew York212011/12/12$106,450
Doris WilderSales AssistantSydney232010/09/20$85,600
Gavin CortezTeam LeaderSan Francisco222008/10/26$235,500
Martena MccrayPost-Sales supportEdinburgh462011/03/09$324,050
Unity ButlerMarketing DesignerSan Francisco472009/12/09$85,675
+
+
+
+
+
+ +
+ +
+@endsection diff --git a/Modules/Leave/resources/views/layouts/master.blade.php b/Modules/Leave/resources/views/layouts/master.blade.php new file mode 100644 index 0000000..17f81bc --- /dev/null +++ b/Modules/Leave/resources/views/layouts/master.blade.php @@ -0,0 +1,29 @@ + + + + + + + + + + Leave Module - {{ config('app.name', 'Laravel') }} + + + + + + + + + + {{-- Vite CSS --}} + {{-- {{ module_vite('build-leave', 'resources/assets/sass/app.scss') }} --}} + + + + @yield('content') + + {{-- Vite JS --}} + {{-- {{ module_vite('build-leave', 'resources/assets/js/app.js') }} --}} + diff --git a/Modules/Leave/resources/views/partials/action.blade.php b/Modules/Leave/resources/views/partials/action.blade.php new file mode 100644 index 0000000..c33288d --- /dev/null +++ b/Modules/Leave/resources/views/partials/action.blade.php @@ -0,0 +1,23 @@ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
diff --git a/Modules/Leave/routes/.gitkeep b/Modules/Leave/routes/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/routes/api.php b/Modules/Leave/routes/api.php new file mode 100644 index 0000000..54310e6 --- /dev/null +++ b/Modules/Leave/routes/api.php @@ -0,0 +1,19 @@ +prefix('v1')->group(function () { + Route::apiResource('leave', LeaveController::class)->names('leave'); +}); diff --git a/Modules/Leave/routes/web.php b/Modules/Leave/routes/web.php new file mode 100644 index 0000000..f99dd31 --- /dev/null +++ b/Modules/Leave/routes/web.php @@ -0,0 +1,19 @@ +names('leave'); +}); diff --git a/Modules/Leave/vite.config.js b/Modules/Leave/vite.config.js new file mode 100644 index 0000000..32835dc --- /dev/null +++ b/Modules/Leave/vite.config.js @@ -0,0 +1,26 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + build: { + outDir: '../../public/build-leave', + emptyOutDir: true, + manifest: true, + }, + plugins: [ + laravel({ + publicDirectory: '../../public', + buildDirectory: 'build-leave', + input: [ + __dirname + '/resources/assets/sass/app.scss', + __dirname + '/resources/assets/js/app.js' + ], + refresh: true, + }), + ], +}); + +//export const paths = [ +// 'Modules/Leave/resources/assets/sass/app.scss', +// 'Modules/Leave/resources/assets/js/app.js', +//]; \ No newline at end of file diff --git a/composer.json b/composer.json index 95be31f..f3be905 100644 --- a/composer.json +++ b/composer.json @@ -6,11 +6,13 @@ "license": "MIT", "require": { "php": "^8.1", + "barryvdh/laravel-debugbar": "^3.13", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^10.0", "laravel/sanctum": "^3.2", "laravel/tinker": "^2.8", "laravel/ui": "^4.5", + "nwidart/laravel-modules": "^11.0", "spatie/laravel-permission": "^6.4", "yoeunes/toastr": "^2.3" }, @@ -27,7 +29,8 @@ "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", - "Database\\Seeders\\": "database/seeders/" + "Database\\Seeders\\": "database/seeders/", + "Modules\\": "Modules/" } }, "autoload-dev": { @@ -63,7 +66,8 @@ "preferred-install": "dist", "sort-packages": true, "allow-plugins": { - "pestphp/pest-plugin": true + "pestphp/pest-plugin": true, + "wikimedia/composer-merge-plugin": true } }, "minimum-stability": "stable", diff --git a/composer.lock b/composer.lock index ba94b94..c0ca3ed 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,92 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e3947aa2fb682a8822517d180dd8cc15", + "content-hash": "18585a0d9833f75d740f42dfc2e2db87", "packages": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.13.3", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "241e9bddb04ab42a04a5fe8b2b9654374c864229" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/241e9bddb04ab42a04a5fe8b2b9654374c864229", + "reference": "241e9bddb04ab42a04a5fe8b2b9654374c864229", + "shasum": "" + }, + "require": { + "illuminate/routing": "^9|^10|^11", + "illuminate/session": "^9|^10|^11", + "illuminate/support": "^9|^10|^11", + "maximebf/debugbar": "~1.22.0", + "php": "^8.0", + "symfony/finder": "^6|^7" + }, + "require-dev": { + "mockery/mockery": "^1.3.3", + "orchestra/testbench-dusk": "^5|^6|^7|^8|^9", + "phpunit/phpunit": "^9.6|^10.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.13-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar" + } + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-debugbar/issues", + "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.13.3" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2024-04-04T02:42:49+00:00" + }, { "name": "brick/math", "version": "0.11.0", @@ -1957,6 +2041,74 @@ ], "time": "2024-01-28T23:22:08+00:00" }, + { + "name": "maximebf/debugbar", + "version": "v1.22.3", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "7aa9a27a0b1158ed5ad4e7175e8d3aee9a818b96" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/7aa9a27a0b1158ed5ad4e7175e8d3aee9a818b96", + "reference": "7aa9a27a0b1158ed5ad4e7175e8d3aee9a818b96", + "shasum": "" + }, + "require": { + "php": "^7.2|^8", + "psr/log": "^1|^2|^3", + "symfony/var-dumper": "^4|^5|^6|^7" + }, + "require-dev": { + "dbrekelmans/bdi": "^1", + "phpunit/phpunit": "^8|^9", + "symfony/panther": "^1|^2.1", + "twig/twig": "^1.38|^2.7|^3.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.22-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "support": { + "issues": "https://github.com/maximebf/php-debugbar/issues", + "source": "https://github.com/maximebf/php-debugbar/tree/v1.22.3" + }, + "time": "2024-04-03T19:39:26+00:00" + }, { "name": "monolog/monolog", "version": "3.5.0", @@ -2457,6 +2609,92 @@ ], "time": "2023-02-08T01:06:31+00:00" }, + { + "name": "nwidart/laravel-modules", + "version": "v11.0.3", + "source": { + "type": "git", + "url": "https://github.com/nWidart/laravel-modules.git", + "reference": "24c5ca340cf9d5cb8d71ebc27e8a5ac70e599a87" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nWidart/laravel-modules/zipball/24c5ca340cf9d5cb8d71ebc27e8a5ac70e599a87", + "reference": "24c5ca340cf9d5cb8d71ebc27e8a5ac70e599a87", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=8.2", + "wikimedia/composer-merge-plugin": "^2.1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^v3.52", + "laravel/framework": "^v11.0", + "mockery/mockery": "^1.6", + "orchestra/testbench": "^v9.0", + "phpstan/phpstan": "^1.4", + "phpunit/phpunit": "^11.0", + "spatie/phpunit-snapshot-assertions": "^5.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Nwidart\\Modules\\LaravelModulesServiceProvider" + ], + "aliases": { + "Module": "Nwidart\\Modules\\Facades\\Module" + } + }, + "branch-alias": { + "dev-master": "11.0-dev" + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Nwidart\\Modules\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com", + "homepage": "https://nicolaswidart.com", + "role": "Developer" + } + ], + "description": "Laravel Module management", + "keywords": [ + "laravel", + "module", + "modules", + "nwidart", + "rad" + ], + "support": { + "issues": "https://github.com/nWidart/laravel-modules/issues", + "source": "https://github.com/nWidart/laravel-modules/tree/v11.0.3" + }, + "funding": [ + { + "url": "https://github.com/dcblogdev", + "type": "github" + }, + { + "url": "https://github.com/nwidart", + "type": "github" + } + ], + "time": "2024-03-24T23:33:15+00:00" + }, { "name": "php-flasher/flasher", "version": "v1.15.14", @@ -6019,6 +6257,62 @@ }, "time": "2022-06-03T18:03:27+00:00" }, + { + "name": "wikimedia/composer-merge-plugin", + "version": "v2.1.0", + "source": { + "type": "git", + "url": "https://github.com/wikimedia/composer-merge-plugin.git", + "reference": "a03d426c8e9fb2c9c569d9deeb31a083292788bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wikimedia/composer-merge-plugin/zipball/a03d426c8e9fb2c9c569d9deeb31a083292788bc", + "reference": "a03d426c8e9fb2c9c569d9deeb31a083292788bc", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1||^2.0", + "php": ">=7.2.0" + }, + "require-dev": { + "composer/composer": "^1.1||^2.0", + "ext-json": "*", + "mediawiki/mediawiki-phan-config": "0.11.1", + "php-parallel-lint/php-parallel-lint": "~1.3.1", + "phpspec/prophecy": "~1.15.0", + "phpunit/phpunit": "^8.5||^9.0", + "squizlabs/php_codesniffer": "~3.7.1" + }, + "type": "composer-plugin", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + }, + "class": "Wikimedia\\Composer\\Merge\\V2\\MergePlugin" + }, + "autoload": { + "psr-4": { + "Wikimedia\\Composer\\Merge\\V2\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bryan Davis", + "email": "bd808@wikimedia.org" + } + ], + "description": "Composer plugin to merge multiple composer.json files", + "support": { + "issues": "https://github.com/wikimedia/composer-merge-plugin/issues", + "source": "https://github.com/wikimedia/composer-merge-plugin/tree/v2.1.0" + }, + "time": "2023-04-15T19:07:00+00:00" + }, { "name": "yoeunes/toastr", "version": "v2.3.5", diff --git a/config/modules.php b/config/modules.php new file mode 100644 index 0000000..e65458e --- /dev/null +++ b/config/modules.php @@ -0,0 +1,259 @@ + 'Modules', + + /* + |-------------------------------------------------------------------------- + | Module Stubs + |-------------------------------------------------------------------------- + | + | Default module stubs. + | + */ + + 'stubs' => [ + 'enabled' => false, + 'path' => base_path('vendor/nwidart/laravel-modules/src/Commands/stubs'), + 'files' => [ + 'routes/web' => 'routes/web.php', + 'routes/api' => 'routes/api.php', + 'views/index' => 'resources/views/index.blade.php', + 'views/master' => 'resources/views/layouts/master.blade.php', + 'scaffold/config' => 'config/config.php', + 'composer' => 'composer.json', + 'assets/js/app' => 'resources/assets/js/app.js', + 'assets/sass/app' => 'resources/assets/sass/app.scss', + 'vite' => 'vite.config.js', + 'package' => 'package.json', + ], + 'replacements' => [ + 'routes/web' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'], + 'routes/api' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'CONTROLLER_NAMESPACE'], + 'vite' => ['LOWER_NAME', 'STUDLY_NAME'], + 'json' => ['LOWER_NAME', 'STUDLY_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'], + 'views/index' => ['LOWER_NAME'], + 'views/master' => ['LOWER_NAME', 'STUDLY_NAME'], + 'scaffold/config' => ['STUDLY_NAME'], + 'composer' => [ + 'LOWER_NAME', + 'STUDLY_NAME', + 'VENDOR', + 'AUTHOR_NAME', + 'AUTHOR_EMAIL', + 'MODULE_NAMESPACE', + 'PROVIDER_NAMESPACE', + ], + ], + 'gitkeep' => true, + ], + 'paths' => [ + /* + |-------------------------------------------------------------------------- + | Modules path + |-------------------------------------------------------------------------- + | + | This path is used to save the generated module. + | This path will also be added automatically to the list of scanned folders. + | + */ + + 'modules' => base_path('Modules'), + /* + |-------------------------------------------------------------------------- + | Modules assets path + |-------------------------------------------------------------------------- + | + | Here you may update the modules' assets path. + | + */ + + 'assets' => public_path('modules'), + /* + |-------------------------------------------------------------------------- + | The migrations' path + |-------------------------------------------------------------------------- + | + | Where you run the 'module:publish-migration' command, where do you publish the + | the migration files? + | + */ + + 'migration' => base_path('database/migrations'), + + /* + |-------------------------------------------------------------------------- + | The app path + |-------------------------------------------------------------------------- + | + | app folder name + | for example can change it to 'src' or 'App' + */ + 'app_folder' => '', + + /* + |-------------------------------------------------------------------------- + | Generator path + |-------------------------------------------------------------------------- + | Customise the paths where the folders will be generated. + | Setting the generate key to false will not generate that folder + */ + 'generator' => [ + // + 'channels' => ['path' => 'Broadcasting', 'generate' => false], + 'command' => ['path' => 'Console', 'generate' => false], + 'emails' => ['path' => 'Emails', 'generate' => false], + 'event' => ['path' => 'Events', 'generate' => false], + 'jobs' => ['path' => 'Jobs', 'generate' => false], + 'listener' => ['path' => 'Listeners', 'generate' => false], + 'model' => ['path' => 'Models', 'generate' => true], + 'notifications' => ['path' => 'Notifications', 'generate' => false], + 'observer' => ['path' => 'Observers', 'generate' => false], + 'policies' => ['path' => 'Policies', 'generate' => false], + 'provider' => ['path' => 'Providers', 'generate' => true], + 'route-provider' => ['path' => 'Providers', 'generate' => true], + 'repository' => ['path' => 'Repositories', 'generate' => true], + 'resource' => ['path' => 'Transformers', 'generate' => false], + 'rules' => ['path' => 'Rules', 'generate' => false], + 'component-class' => ['path' => 'View/Components', 'generate' => false], + + // Http/ + 'controller' => ['path' => 'Http/Controllers', 'generate' => true], + 'filter' => ['path' => 'Http/Middleware', 'generate' => false], + 'request' => ['path' => 'Http/Requests', 'generate' => false], + + // config/ + 'config' => ['path' => 'config', 'generate' => true], + + // database/ + 'migration' => ['path' => 'database/migrations', 'generate' => true], + 'seeder' => ['path' => 'database/seeders', 'generate' => true], + 'factory' => ['path' => 'database/factories', 'generate' => false], + + // lang/ + 'lang' => ['path' => 'lang', 'generate' => false], + + // resource/ + 'assets' => ['path' => 'resources/assets', 'generate' => true], + 'views' => ['path' => 'resources/views', 'generate' => true], + 'component-view' => ['path' => 'resources/views/components', 'generate' => false], + + // routes/ + 'routes' => ['path' => 'routes', 'generate' => true], + + // tests/ + 'test-unit' => ['path' => 'tests/Unit', 'generate' => false], + 'test-feature' => ['path' => 'tests/Feature', 'generate' => false], + ], + ], + + /* + |-------------------------------------------------------------------------- + | Package commands + |-------------------------------------------------------------------------- + | + | Here you can define which commands will be visible and used in your + | application. You can add your own commands to merge section. + | + */ + 'commands' => ConsoleServiceProvider::defaultCommands() + ->merge([ + // New commands go here + ])->toArray(), + + /* + |-------------------------------------------------------------------------- + | Scan Path + |-------------------------------------------------------------------------- + | + | Here you define which folder will be scanned. By default will scan vendor + | directory. This is useful if you host the package in packagist website. + | + */ + + 'scan' => [ + 'enabled' => false, + 'paths' => [ + base_path('vendor/*/*'), + ], + ], + /* + |-------------------------------------------------------------------------- + | Composer File Template + |-------------------------------------------------------------------------- + | + | Here is the config for the composer.json file, generated by this package + | + */ + + 'composer' => [ + 'vendor' => env('MODULES_VENDOR', 'nwidart'), + 'author' => [ + 'name' => env('MODULES_NAME', 'Nicolas Widart'), + 'email' => env('MODULES_EMAIL', 'n.widart@gmail.com'), + ], + 'composer-output' => false, + ], + + /* + |-------------------------------------------------------------------------- + | Caching + |-------------------------------------------------------------------------- + | + | Here is the config for setting up the caching feature. + | + */ + 'cache' => [ + 'enabled' => false, + 'driver' => 'file', + 'key' => 'laravel-modules', + 'lifetime' => 60, + ], + /* + |-------------------------------------------------------------------------- + | Choose what laravel-modules will register as custom namespaces. + | Setting one to false will require you to register that part + | in your own Service Provider class. + |-------------------------------------------------------------------------- + */ + 'register' => [ + 'translations' => true, + /** + * load files on boot or register method + */ + 'files' => 'register', + ], + + /* + |-------------------------------------------------------------------------- + | Activators + |-------------------------------------------------------------------------- + | + | You can define new types of activators here, file, database, etc. The only + | required parameter is 'class'. + | The file activator will store the activation status in storage/installed_modules + */ + 'activators' => [ + 'file' => [ + 'class' => FileActivator::class, + 'statuses-file' => base_path('modules_statuses.json'), + 'cache-key' => 'activator.installed', + 'cache-lifetime' => 604800, + ], + ], + + 'activator' => 'file', +]; diff --git a/modules_statuses.json b/modules_statuses.json new file mode 100644 index 0000000..bf189e4 --- /dev/null +++ b/modules_statuses.json @@ -0,0 +1,4 @@ +{ + "Leave": true, + "Attendance": true +} \ No newline at end of file diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 6f55823..8407633 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -14,6 +14,12 @@ + + + + + + @@ -106,6 +112,16 @@ + + + + + + + + + + diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index 5b5aefd..bda2609 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -63,6 +63,13 @@ + + + diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/storage/debugbar/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/stubs/nwidart-stubs/assets/js/app.stub b/stubs/nwidart-stubs/assets/js/app.stub new file mode 100644 index 0000000..e69de29 diff --git a/stubs/nwidart-stubs/assets/sass/app.stub b/stubs/nwidart-stubs/assets/sass/app.stub new file mode 100644 index 0000000..e69de29 diff --git a/stubs/nwidart-stubs/channel.stub b/stubs/nwidart-stubs/channel.stub new file mode 100644 index 0000000..f68b0b0 --- /dev/null +++ b/stubs/nwidart-stubs/channel.stub @@ -0,0 +1,24 @@ + + + diff --git a/stubs/nwidart-stubs/composer.stub b/stubs/nwidart-stubs/composer.stub new file mode 100644 index 0000000..d1500a2 --- /dev/null +++ b/stubs/nwidart-stubs/composer.stub @@ -0,0 +1,30 @@ +{ + "name": "$VENDOR$/$LOWER_NAME$", + "description": "", + "authors": [ + { + "name": "$AUTHOR_NAME$", + "email": "$AUTHOR_EMAIL$" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\": "app/", + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Factories\\": "database/factories/", + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Tests\\": "tests/" + } + } +} diff --git a/stubs/nwidart-stubs/controller-api.stub b/stubs/nwidart-stubs/controller-api.stub new file mode 100644 index 0000000..025095d --- /dev/null +++ b/stubs/nwidart-stubs/controller-api.stub @@ -0,0 +1,59 @@ +json([]); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + + return response()->json([]); + } + + /** + * Show the specified resource. + */ + public function show($id) + { + // + + return response()->json([]); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id) + { + // + + return response()->json([]); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy($id) + { + // + + return response()->json([]); + } +} diff --git a/stubs/nwidart-stubs/controller-plain.stub b/stubs/nwidart-stubs/controller-plain.stub new file mode 100644 index 0000000..662b072 --- /dev/null +++ b/stubs/nwidart-stubs/controller-plain.stub @@ -0,0 +1,9 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/stubs/nwidart-stubs/job-queued.stub b/stubs/nwidart-stubs/job-queued.stub new file mode 100644 index 0000000..26dd3f0 --- /dev/null +++ b/stubs/nwidart-stubs/job-queued.stub @@ -0,0 +1,30 @@ +view('view.name'); + } +} diff --git a/stubs/nwidart-stubs/middleware.stub b/stubs/nwidart-stubs/middleware.stub new file mode 100644 index 0000000..bdd192d --- /dev/null +++ b/stubs/nwidart-stubs/middleware.stub @@ -0,0 +1,17 @@ +id(); + $FIELDS$ + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('$TABLE$'); + } +}; diff --git a/stubs/nwidart-stubs/migration/delete.stub b/stubs/nwidart-stubs/migration/delete.stub new file mode 100644 index 0000000..788cdee --- /dev/null +++ b/stubs/nwidart-stubs/migration/delete.stub @@ -0,0 +1,28 @@ +id(); + $FIELDS$ + $table->timestamps(); + }); + } +}; diff --git a/stubs/nwidart-stubs/migration/plain.stub b/stubs/nwidart-stubs/migration/plain.stub new file mode 100644 index 0000000..88fa2f3 --- /dev/null +++ b/stubs/nwidart-stubs/migration/plain.stub @@ -0,0 +1,24 @@ +line('The introduction to the notification.') + ->action('Notification Action', 'https://laravel.com') + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + */ + public function toArray($notifiable): array + { + return []; + } +} diff --git a/stubs/nwidart-stubs/observer.stub b/stubs/nwidart-stubs/observer.stub new file mode 100644 index 0000000..ca49863 --- /dev/null +++ b/stubs/nwidart-stubs/observer.stub @@ -0,0 +1,48 @@ +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('$MODULE$', '$WEB_ROUTES_PATH$')); + } + + /** + * 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('$MODULE$', '$API_ROUTES_PATH$')); + } +} diff --git a/stubs/nwidart-stubs/routes/api.stub b/stubs/nwidart-stubs/routes/api.stub new file mode 100644 index 0000000..c99a9bb --- /dev/null +++ b/stubs/nwidart-stubs/routes/api.stub @@ -0,0 +1,19 @@ +prefix('v1')->group(function () { + Route::apiResource('$LOWER_NAME$', $STUDLY_NAME$Controller::class)->names('$LOWER_NAME$'); +}); diff --git a/stubs/nwidart-stubs/routes/web.stub b/stubs/nwidart-stubs/routes/web.stub new file mode 100644 index 0000000..c00f766 --- /dev/null +++ b/stubs/nwidart-stubs/routes/web.stub @@ -0,0 +1,19 @@ +names('$LOWER_NAME$'); +}); diff --git a/stubs/nwidart-stubs/rule.implicit.stub b/stubs/nwidart-stubs/rule.implicit.stub new file mode 100644 index 0000000..edc029c --- /dev/null +++ b/stubs/nwidart-stubs/rule.implicit.stub @@ -0,0 +1,22 @@ + '$STUDLY_NAME$', +]; diff --git a/stubs/nwidart-stubs/scaffold/provider.stub b/stubs/nwidart-stubs/scaffold/provider.stub new file mode 100644 index 0000000..b6aa804 --- /dev/null +++ b/stubs/nwidart-stubs/scaffold/provider.stub @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, '$MIGRATIONS_PATH$')); + } + + /** + * 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, '$PATH_LANG$'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, '$PATH_LANG$')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, '$PATH_CONFIG$/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, '$PATH_CONFIG$/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, '$PATH_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/stubs/nwidart-stubs/seeder.stub b/stubs/nwidart-stubs/seeder.stub new file mode 100644 index 0000000..3882d1c --- /dev/null +++ b/stubs/nwidart-stubs/seeder.stub @@ -0,0 +1,16 @@ +call([]); + } +} diff --git a/stubs/nwidart-stubs/unit-test.stub b/stubs/nwidart-stubs/unit-test.stub new file mode 100644 index 0000000..be0bd55 --- /dev/null +++ b/stubs/nwidart-stubs/unit-test.stub @@ -0,0 +1,20 @@ +assertTrue(true); + } +} diff --git a/stubs/nwidart-stubs/view.stub b/stubs/nwidart-stubs/view.stub new file mode 100644 index 0000000..c7ab22b --- /dev/null +++ b/stubs/nwidart-stubs/view.stub @@ -0,0 +1,3 @@ +
+ +
diff --git a/stubs/nwidart-stubs/views/index.stub b/stubs/nwidart-stubs/views/index.stub new file mode 100644 index 0000000..1a535d4 --- /dev/null +++ b/stubs/nwidart-stubs/views/index.stub @@ -0,0 +1,7 @@ +@extends('$LOWER_NAME$::layouts.master') + +@section('content') +

Hello World

+ +

Module: {!! config('$LOWER_NAME$.name') !!}

+@endsection diff --git a/stubs/nwidart-stubs/views/master.stub b/stubs/nwidart-stubs/views/master.stub new file mode 100644 index 0000000..8fa6ac4 --- /dev/null +++ b/stubs/nwidart-stubs/views/master.stub @@ -0,0 +1,29 @@ + + + + + + + + + + $STUDLY_NAME$ Module - {{ config('app.name', 'Laravel') }} + + + + + + + + + + {{-- Vite CSS --}} + {{-- {{ module_vite('build-$LOWER_NAME$', 'resources/assets/sass/app.scss') }} --}} + + + + @yield('content') + + {{-- Vite JS --}} + {{-- {{ module_vite('build-$LOWER_NAME$', 'resources/assets/js/app.js') }} --}} + diff --git a/stubs/nwidart-stubs/vite.stub b/stubs/nwidart-stubs/vite.stub new file mode 100644 index 0000000..314ef81 --- /dev/null +++ b/stubs/nwidart-stubs/vite.stub @@ -0,0 +1,26 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + build: { + outDir: '../../public/build-$LOWER_NAME$', + emptyOutDir: true, + manifest: true, + }, + plugins: [ + laravel({ + publicDirectory: '../../public', + buildDirectory: 'build-$LOWER_NAME$', + input: [ + __dirname + '/resources/assets/sass/app.scss', + __dirname + '/resources/assets/js/app.js' + ], + refresh: true, + }), + ], +}); + +//export const paths = [ +// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss', +// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js', +//]; \ No newline at end of file diff --git a/vite-module-loader.js b/vite-module-loader.js new file mode 100644 index 0000000..ab41f22 --- /dev/null +++ b/vite-module-loader.js @@ -0,0 +1,45 @@ +import fs from 'fs/promises'; +import path from 'path'; + +async function collectModuleAssetsPaths(paths, modulesPath) { + modulesPath = path.join(__dirname, modulesPath); + + const moduleStatusesPath = path.join(__dirname, 'modules_statuses.json'); + + try { + // Read module_statuses.json + const moduleStatusesContent = await fs.readFile(moduleStatusesPath, 'utf-8'); + const moduleStatuses = JSON.parse(moduleStatusesContent); + + // Read module directories + const moduleDirectories = await fs.readdir(modulesPath); + + for (const moduleDir of moduleDirectories) { + if (moduleDir === '.DS_Store') { + // Skip .DS_Store directory + continue; + } + + // Check if the module is enabled (status is true) + if (moduleStatuses[moduleDir] === true) { + const viteConfigPath = path.join(modulesPath, moduleDir, 'vite.config.js'); + const stat = await fs.stat(viteConfigPath); + + if (stat.isFile()) { + // Import the module-specific Vite configuration + const moduleConfig = await import(viteConfigPath); + + if (moduleConfig.paths && Array.isArray(moduleConfig.paths)) { + paths.push(...moduleConfig.paths); + } + } + } + } + } catch (error) { + console.error(`Error reading module statuses or module configurations: ${error}`); + } + + return paths; +} + +export default collectModuleAssetsPaths;