diff --git a/Modules/Leave/app/Http/Controllers/.gitkeep b/Modules/Leave/app/Http/Controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/app/Http/Controllers/LeaveController.php b/Modules/Leave/app/Http/Controllers/LeaveController.php new file mode 100644 index 0000000..7f65e29 --- /dev/null +++ b/Modules/Leave/app/Http/Controllers/LeaveController.php @@ -0,0 +1,84 @@ +leaveRepository = $leaveRepository; + } + + /** + * Display a listing of the resource. + */ + public function index() + { + $data['leaves'] = $this->leaveRepository->findAll(); + // dd($data['leaves']); + 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 + { + $inputData = $request->all(); + try { + $this->leaveRepository->create($inputData); + toastr()->success('Leave Created Succesfully'); + } catch (\Throwable $th) { + toastr()->error($th->getMessage()); + } + return redirect()->route('leave.index'); + } + + /** + * 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/app/Http/Requests/.gitkeep b/Modules/Leave/app/Http/Requests/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/app/Models/.gitkeep b/Modules/Leave/app/Models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/app/Models/Leave.php b/Modules/Leave/app/Models/Leave.php new file mode 100644 index 0000000..48f2185 --- /dev/null +++ b/Modules/Leave/app/Models/Leave.php @@ -0,0 +1,12 @@ +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->bind(LeaveInterface::class, LeaveRepository::class); + $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/app/Providers/RouteServiceProvider.php b/Modules/Leave/app/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..29b900e --- /dev/null +++ b/Modules/Leave/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('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/app/Repositories/.gitkeep b/Modules/Leave/app/Repositories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/app/Repositories/LeaveInterface.php b/Modules/Leave/app/Repositories/LeaveInterface.php new file mode 100644 index 0000000..d34795e --- /dev/null +++ b/Modules/Leave/app/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/factories/.gitkeep b/Modules/Leave/database/factories/.gitkeep new file mode 100644 index 0000000..e69de29 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..0accbdc --- /dev/null +++ b/Modules/Leave/database/migrations/2024_04_04_102430_create_leaves_table.php @@ -0,0 +1,30 @@ +tinyInteger('leave_id')->unsigned()->autoIncrement(); + $table->integer('employee_id'); + $table->date('start_date'); + $table->date('end_date'); + $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..22a97da --- /dev/null +++ b/Modules/Leave/resources/views/create.blade.php @@ -0,0 +1,44 @@ +@extends('layouts.app') + +@section('content') +
Name | +Position | +Office | +Age | +Start date | +Salary | +
---|---|---|---|---|---|
Tiger Nixon | +System Architect | +Edinburgh | +61 | +2011/04/25 | +$320,800 | +
Garrett Winters | +Accountant | +Tokyo | +63 | +2011/07/25 | +$170,750 | +
Ashton Cox | +Junior Technical Author | +San Francisco | +66 | +2009/01/12 | +$86,000 | +
Cedric Kelly | +Senior Javascript Developer | +Edinburgh | +22 | +2012/03/29 | +$433,060 | +
Airi Satou | +Accountant | +Tokyo | +33 | +2008/11/28 | +$162,700 | +
Brielle Williamson | +Integration Specialist | +New York | +61 | +2012/12/02 | +$372,000 | +
Herrod Chandler | +Sales Assistant | +San Francisco | +59 | +2012/08/06 | +$137,500 | +
Rhona Davidson | +Integration Specialist | +Tokyo | +55 | +2010/10/14 | +$327,900 | +
Colleen Hurst | +Javascript Developer | +San Francisco | +39 | +2009/09/15 | +$205,500 | +
Sonya Frost | +Software Engineer | +Edinburgh | +23 | +2008/12/13 | +$103,600 | +
Jena Gaines | +Office Manager | +London | +30 | +2008/12/19 | +$90,560 | +
Quinn Flynn | +Support Lead | +Edinburgh | +22 | +2013/03/03 | +$342,000 | +
Charde Marshall | +Regional Director | +San Francisco | +36 | +2008/10/16 | +$470,600 | +
Haley Kennedy | +Senior Marketing Designer | +London | +43 | +2012/12/18 | +$313,500 | +
Tatyana Fitzpatrick | +Regional Director | +London | +19 | +2010/03/17 | +$385,750 | +
Michael Silva | +Marketing Designer | +London | +66 | +2012/11/27 | +$198,500 | +
Paul Byrd | +Chief Financial Officer (CFO) | +New York | +64 | +2010/06/09 | +$725,000 | +
Gloria Little | +Systems Administrator | +New York | +59 | +2009/04/10 | +$237,500 | +
Bradley Greer | +Software Engineer | +London | +41 | +2012/10/13 | +$132,000 | +
Dai Rios | +Personnel Lead | +Edinburgh | +35 | +2012/09/26 | +$217,500 | +
Jenette Caldwell | +Development Lead | +New York | +30 | +2011/09/03 | +$345,000 | +
Yuri Berry | +Chief Marketing Officer (CMO) | +New York | +40 | +2009/06/25 | +$675,000 | +
Caesar Vance | +Pre-Sales Support | +New York | +21 | +2011/12/12 | +$106,450 | +
Doris Wilder | +Sales Assistant | +Sydney | +23 | +2010/09/20 | +$85,600 | +
Gavin Cortez | +Team Leader | +San Francisco | +22 | +2008/10/26 | +$235,500 | +
Martena Mccray | +Post-Sales support | +Edinburgh | +46 | +2011/03/09 | +$324,050 | +
Unity Butler | +Marketing Designer | +San Francisco | +47 | +2009/12/09 | +$85,675 | +