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') +
+
+ +
+
+
+

{{ $title }}

+ +
+ +
+ +
+
+
+ +
+
+
+
+
+ @csrf + @include('leave::partials.action') +
+
+
+
+
+ + +
+ +
+@endsection + +@push('js') + +@endpush 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..bae23c3 --- /dev/null +++ b/Modules/Leave/resources/views/partials/action.blade.php @@ -0,0 +1,27 @@ +
+ + +
+ Please enter Employee Name. +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
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