diff --git a/Modules/Leave/app/Http/Controllers/LeaveController.php b/Modules/Leave/app/Http/Controllers/LeaveController.php index 236e547..5d3b68b 100644 --- a/Modules/Leave/app/Http/Controllers/LeaveController.php +++ b/Modules/Leave/app/Http/Controllers/LeaveController.php @@ -33,8 +33,7 @@ class LeaveController extends Controller { $data['leaves'] = $this->leaveRepository->findAll(); $data['employeeList'] = $this->employeeRepository->pluck(); - - return view('leave::index', $data); + return view('leave::leave.index', $data); } /** @@ -44,7 +43,7 @@ class LeaveController extends Controller { $data['title'] = 'Create Leave'; $data['employeeList'] = $this->employeeRepository->pluck(); - return view('leave::create', $data); + return view('leave::leave.create', $data); } /** @@ -67,7 +66,7 @@ class LeaveController extends Controller */ public function show($id) { - return view('leave::show'); + return view('leave::leave.show'); } /** @@ -79,7 +78,7 @@ class LeaveController extends Controller $data['leave'] = $this->leaveRepository->getLeaveById($id); - return view('leave::edit', $data); + return view('leave::leave.edit', $data); } /** diff --git a/Modules/Leave/app/Http/Controllers/LeaveTypeController.php b/Modules/Leave/app/Http/Controllers/LeaveTypeController.php new file mode 100644 index 0000000..f07bace --- /dev/null +++ b/Modules/Leave/app/Http/Controllers/LeaveTypeController.php @@ -0,0 +1,80 @@ +leaveRepository = $leaveRepository; + $this->leaveTypeRepository = $leaveTypeRepository; + } + /** + * Display a listing of the resource. + */ + public function index() + { + $data['leaveTypes'] = $this->leaveTypeRepository->findAll(); + return view('leave::leave-type.index', $data); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + $data['title'] = 'Create Leave Type'; + + return view('leave::leave-type.create', $data); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request): RedirectResponse + { + // + } + + /** + * Show the specified resource. + */ + public function show($id) + { + return view('leave::leave-type.show'); + } + + /** + * Show the form for editing the specified resource. + */ + public function edit($id) + { + return view('leave::leave-type.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/LeaveTypeRequest.php b/Modules/Leave/app/Http/Requests/LeaveTypeRequest.php new file mode 100644 index 0000000..76c9601 --- /dev/null +++ b/Modules/Leave/app/Http/Requests/LeaveTypeRequest.php @@ -0,0 +1,26 @@ +app->bind(LeaveInterface::class, LeaveRepository::class); + $this->app->bind(LeaveTypeInterface::class, LeaveTypeRepository::class); + $this->app->register(RouteServiceProvider::class); } @@ -60,7 +63,7 @@ class LeaveServiceProvider extends ServiceProvider */ public function registerTranslations(): void { - $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + $langPath = resource_path('lang/modules/' . $this->moduleNameLower); if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, $this->moduleNameLower); @@ -76,7 +79,7 @@ class LeaveServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $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); } @@ -85,14 +88,14 @@ class LeaveServiceProvider extends ServiceProvider */ public function registerViews(): void { - $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $viewPath = resource_path('views/modules/' . $this->moduleNameLower); $sourcePath = module_path($this->moduleName, 'resources/views'); - $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-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',''))); + $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); } @@ -108,8 +111,8 @@ class LeaveServiceProvider extends ServiceProvider { $paths = []; foreach (config('view.paths') as $path) { - if (is_dir($path.'/modules/'.$this->moduleNameLower)) { - $paths[] = $path.'/modules/'.$this->moduleNameLower; + if (is_dir($path . '/modules/' . $this->moduleNameLower)) { + $paths[] = $path . '/modules/' . $this->moduleNameLower; } } diff --git a/Modules/Leave/app/Repositories/LeaveTypeInterface.php b/Modules/Leave/app/Repositories/LeaveTypeInterface.php new file mode 100644 index 0000000..870e937 --- /dev/null +++ b/Modules/Leave/app/Repositories/LeaveTypeInterface.php @@ -0,0 +1,12 @@ +update($newDetails); + } + +} 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 index 0accbdc..9c2834b 100644 --- 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 @@ -11,11 +11,12 @@ return new class extends Migration */ public function up(): void { - Schema::create('leaves', function (Blueprint $table) { + Schema::create('tbl_leaves', function (Blueprint $table) { $table->tinyInteger('leave_id')->unsigned()->autoIncrement(); - $table->integer('employee_id'); - $table->date('start_date'); - $table->date('end_date'); + $table->unsignedBigInteger('employee_id'); + $table->unsignedBigInteger('leave_type_id'); + $table->date('start_date')->nullable(); + $table->date('end_date')->nullable(); $table->timestamps(); }); } @@ -25,6 +26,6 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('leaves'); + Schema::dropIfExists('tbl_leaves'); } }; diff --git a/Modules/Leave/database/migrations/2024_04_11_110941_create_leave_types_table.php b/Modules/Leave/database/migrations/2024_04_11_110941_create_leave_types_table.php new file mode 100644 index 0000000..774ff92 --- /dev/null +++ b/Modules/Leave/database/migrations/2024_04_11_110941_create_leave_types_table.php @@ -0,0 +1,31 @@ +tinyInteger('leave_type_id')->unsigned()->autoIncrement(); + $table->string('title'); + $table->integer('status')->default(11); + $table->integer('createdBy')->nullable(); + $table->integer('updatedBy')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('tbl_leave_types'); + } +}; diff --git a/Modules/Leave/resources/views/leave-type/create.blade.php b/Modules/Leave/resources/views/leave-type/create.blade.php new file mode 100644 index 0000000..8fab614 --- /dev/null +++ b/Modules/Leave/resources/views/leave-type/create.blade.php @@ -0,0 +1,30 @@ +@extends('layouts.app') + +@section('content') +
+
+ + @include('layouts.partials.breadcrumb', ['title' => $title]) + +
+
+
+
+
+ @csrf + @include('leave::leave.partials.action') +
+
+
+
+
+ + +
+ +
+@endsection + +@push('js') + +@endpush diff --git a/Modules/Leave/resources/views/edit.blade.php b/Modules/Leave/resources/views/leave-type/edit.blade.php similarity index 95% rename from Modules/Leave/resources/views/edit.blade.php rename to Modules/Leave/resources/views/leave-type/edit.blade.php index 4644d7c..a780d69 100644 --- a/Modules/Leave/resources/views/edit.blade.php +++ b/Modules/Leave/resources/views/leave-type/edit.blade.php @@ -27,7 +27,7 @@ {{ html()->modelForm($leave, 'PUT')->route('leave.update', $leave->id)->class(['needs-validation'])->attributes(['novalidate'])->open() }} - @include('leave::partials.action') + @include('leave::leave.partials.action') {{ html()->closeModelForm() }} diff --git a/Modules/Leave/resources/views/leave-type/index.blade.php b/Modules/Leave/resources/views/leave-type/index.blade.php new file mode 100644 index 0000000..ff62f20 --- /dev/null +++ b/Modules/Leave/resources/views/leave-type/index.blade.php @@ -0,0 +1,68 @@ +@extends('layouts.app') + +@section('content') +
+
+ + +
+
+
+
+
Leave Lists
+
+ Add +
+
+ +
+
+ + + + + + + + + + + + @forelse ($leaveTypes as $key => $leaveType) + + + + + + + + + @empty + @endforelse + +
S.NLeave TypeCreated ByStatusAction
{{ $key + 1 }}{{ $leaveType->employee_id }}{{ $leaveType->start_date }}{{ $leaveType->end_date }}{{ $leaveType->created_at }} +
+ + + + + + + +
+
+
+
+
+
+
+ +
+
+@endsection diff --git a/Modules/Leave/resources/views/partials/action.blade.php b/Modules/Leave/resources/views/leave-type/partials/action.blade.php similarity index 100% rename from Modules/Leave/resources/views/partials/action.blade.php rename to Modules/Leave/resources/views/leave-type/partials/action.blade.php diff --git a/Modules/Leave/resources/views/partials/view.blade.php b/Modules/Leave/resources/views/leave-type/partials/view.blade.php similarity index 92% rename from Modules/Leave/resources/views/partials/view.blade.php rename to Modules/Leave/resources/views/leave-type/partials/view.blade.php index c17e8df..67a8c0e 100644 --- a/Modules/Leave/resources/views/partials/view.blade.php +++ b/Modules/Leave/resources/views/leave-type/partials/view.blade.php @@ -8,7 +8,7 @@ diff --git a/Modules/Leave/resources/views/show.blade.php b/Modules/Leave/resources/views/leave-type/show.blade.php similarity index 100% rename from Modules/Leave/resources/views/show.blade.php rename to Modules/Leave/resources/views/leave-type/show.blade.php diff --git a/Modules/Leave/resources/views/create.blade.php b/Modules/Leave/resources/views/leave/create.blade.php similarity index 93% rename from Modules/Leave/resources/views/create.blade.php rename to Modules/Leave/resources/views/leave/create.blade.php index b757afb..f23692f 100644 --- a/Modules/Leave/resources/views/create.blade.php +++ b/Modules/Leave/resources/views/leave/create.blade.php @@ -12,7 +12,7 @@
@csrf - @include('leave::partials.action') + @include('leave::leave.partials.action')
diff --git a/Modules/Leave/resources/views/leave/edit.blade.php b/Modules/Leave/resources/views/leave/edit.blade.php new file mode 100644 index 0000000..a780d69 --- /dev/null +++ b/Modules/Leave/resources/views/leave/edit.blade.php @@ -0,0 +1,47 @@ +@extends('layouts.app') + +@section('content') +
+
+ +
+
+
+

{{ $title }}

+ +
+ +
+ +
+
+
+ +
+
+
+
+ + {{ html()->modelForm($leave, 'PUT')->route('leave.update', $leave->id)->class(['needs-validation'])->attributes(['novalidate'])->open() }} + + @include('leave::leave.partials.action') + + {{ html()->closeModelForm() }} + +
+
+
+
+ + +
+ +
+@endsection + +@push('js') + +@endpush diff --git a/Modules/Leave/resources/views/index.blade.php b/Modules/Leave/resources/views/leave/index.blade.php similarity index 99% rename from Modules/Leave/resources/views/index.blade.php rename to Modules/Leave/resources/views/leave/index.blade.php index 01fea4b..557993e 100644 --- a/Modules/Leave/resources/views/index.blade.php +++ b/Modules/Leave/resources/views/leave/index.blade.php @@ -104,5 +104,5 @@ - @include('leave::partials.view') + @include('leave::leave.partials.view') @endsection diff --git a/Modules/Leave/resources/views/leave/partials/action.blade.php b/Modules/Leave/resources/views/leave/partials/action.blade.php new file mode 100644 index 0000000..a0c05f3 --- /dev/null +++ b/Modules/Leave/resources/views/leave/partials/action.blade.php @@ -0,0 +1,24 @@ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +@push('js') + +@endpush diff --git a/Modules/Leave/resources/views/leave/partials/view.blade.php b/Modules/Leave/resources/views/leave/partials/view.blade.php new file mode 100644 index 0000000..67a8c0e --- /dev/null +++ b/Modules/Leave/resources/views/leave/partials/view.blade.php @@ -0,0 +1,16 @@ + diff --git a/Modules/Leave/resources/views/leave/show.blade.php b/Modules/Leave/resources/views/leave/show.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Leave/routes/web.php b/Modules/Leave/routes/web.php index f99dd31..c3d6b11 100644 --- a/Modules/Leave/routes/web.php +++ b/Modules/Leave/routes/web.php @@ -2,6 +2,7 @@ use Illuminate\Support\Facades\Route; use Modules\Leave\Http\Controllers\LeaveController; +use Modules\Leave\Http\Controllers\LeaveTypeController; /* |-------------------------------------------------------------------------- @@ -12,8 +13,10 @@ use Modules\Leave\Http\Controllers\LeaveController; | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | -*/ + */ Route::group([], function () { Route::resource('leave', LeaveController::class)->names('leave'); + Route::resource('leave-type', LeaveTypeController::class)->names('leaveType'); + }); diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index 1a75d97..23c4d6a 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -86,9 +86,24 @@