diff --git a/Modules/Employee/Http/Controllers/.gitkeep b/Modules/Employee/app/Http/Controllers/.gitkeep similarity index 100% rename from Modules/Employee/Http/Controllers/.gitkeep rename to Modules/Employee/app/Http/Controllers/.gitkeep diff --git a/Modules/Employee/Http/Controllers/EmployeeController.php b/Modules/Employee/app/Http/Controllers/EmployeeController.php similarity index 100% rename from Modules/Employee/Http/Controllers/EmployeeController.php rename to Modules/Employee/app/Http/Controllers/EmployeeController.php diff --git a/Modules/Employee/Models/.gitkeep b/Modules/Employee/app/Models/.gitkeep similarity index 100% rename from Modules/Employee/Models/.gitkeep rename to Modules/Employee/app/Models/.gitkeep diff --git a/Modules/Employee/app/Models/Employee.php b/Modules/Employee/app/Models/Employee.php new file mode 100644 index 0000000..7002cf2 --- /dev/null +++ b/Modules/Employee/app/Models/Employee.php @@ -0,0 +1,13 @@ +app->bind(EmployeeInterface::class, EmployeeRepository::class); $this->app->register(RouteServiceProvider::class); } diff --git a/Modules/Employee/Providers/RouteServiceProvider.php b/Modules/Employee/app/Providers/RouteServiceProvider.php similarity index 100% rename from Modules/Employee/Providers/RouteServiceProvider.php rename to Modules/Employee/app/Providers/RouteServiceProvider.php diff --git a/Modules/Employee/Repositories/.gitkeep b/Modules/Employee/app/Repositories/.gitkeep similarity index 100% rename from Modules/Employee/Repositories/.gitkeep rename to Modules/Employee/app/Repositories/.gitkeep diff --git a/Modules/Employee/app/Repositories/EmployeeInterface.php b/Modules/Employee/app/Repositories/EmployeeInterface.php new file mode 100644 index 0000000..947e916 --- /dev/null +++ b/Modules/Employee/app/Repositories/EmployeeInterface.php @@ -0,0 +1,12 @@ +update($newDetails); + } + +} diff --git a/Modules/Leave/app/Http/Controllers/LeaveController.php b/Modules/Leave/app/Http/Controllers/LeaveController.php index 7f65e29..3ca1131 100644 --- a/Modules/Leave/app/Http/Controllers/LeaveController.php +++ b/Modules/Leave/app/Http/Controllers/LeaveController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Modules\Leave\Repositories\LeaveInterface; +use Yoeunes\Toastr\Facades\Toastr; class LeaveController extends Controller { @@ -14,6 +15,12 @@ class LeaveController extends Controller public function __construct(LeaveInterface $leaveRepository) { $this->leaveRepository = $leaveRepository; + + $this->middleware('role_or_permission:access leaves|create leaves|edit leaves|delete leaves', ['only' => ['index', 'show']]); + $this->middleware('role_or_permission:create leaves', ['only' => ['create', 'store']]); + $this->middleware('role_or_permission:edit leaves', ['only' => ['edit', 'update']]); + $this->middleware('role_or_permission:delete leaves', ['only' => ['destroy']]); + } /** @@ -22,8 +29,7 @@ class LeaveController extends Controller public function index() { $data['leaves'] = $this->leaveRepository->findAll(); - // dd($data['leaves']); - return view('leave::index'); + return view('leave::index',$data); } /** @@ -43,7 +49,7 @@ class LeaveController extends Controller $inputData = $request->all(); try { $this->leaveRepository->create($inputData); - toastr()->success('Leave Created Succesfully'); + Toastr()->success('Leave Created Succesfully'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } @@ -63,7 +69,9 @@ class LeaveController extends Controller */ public function edit($id) { - return view('leave::edit'); + $data['title'] = 'Edit Leave'; + $data['leave'] = $this->leaveRepository->getLeaveById($id); + return view('leave::edit',$data); } /** @@ -71,7 +79,14 @@ class LeaveController extends Controller */ public function update(Request $request, $id): RedirectResponse { - // + $inputData = $request->all(); + try { + $this->leaveRepository->update($id,$inputData); + toastr()->success('Leave Updated Succesfully'); + } catch (\Throwable $th) { + toastr()->error($th->getMessage()); + } + return redirect()->route('leave.index'); } /** @@ -79,6 +94,7 @@ class LeaveController extends Controller */ public function destroy($id) { - // + $this->leaveRepository->delete($id); + toastr()->success('Leave Deleted Succesfully'); } } diff --git a/Modules/Leave/app/Models/Leave.php b/Modules/Leave/app/Models/Leave.php index 48f2185..c691311 100644 --- a/Modules/Leave/app/Models/Leave.php +++ b/Modules/Leave/app/Models/Leave.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model; class Leave extends Model { protected $table = 'leaves'; + protected $primaryKey = 'leave_id'; protected $guarded = []; } diff --git a/Modules/Leave/app/Repositories/LeaveRepository.php b/Modules/Leave/app/Repositories/LeaveRepository.php index abdb3a5..e62b14f 100644 --- a/Modules/Leave/app/Repositories/LeaveRepository.php +++ b/Modules/Leave/app/Repositories/LeaveRepository.php @@ -28,7 +28,7 @@ class LeaveRepository implements LeaveInterface public function update($leaveId, array $newDetails) { - return Leave::whereId($leaveId)->update($newDetails); + return Leave::where('leave_id',$leaveId)->update($newDetails); } } diff --git a/Modules/Leave/resources/views/edit.blade.php b/Modules/Leave/resources/views/edit.blade.php new file mode 100644 index 0000000..67912e4 --- /dev/null +++ b/Modules/Leave/resources/views/edit.blade.php @@ -0,0 +1,47 @@ +@extends('layouts.app') + +@section('content') +
Name | -Position | -Office | -Age | -Start date | -Salary | +S.N | +Employee Name | +Start Date | +End Date | +Created At | +Action | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | -||||||||||||||||||
{{ $key + 1 }} | +{{ $leave->employee_id }} | +{{ $leave->start_date }} | +{{ $leave->end_date }} | +{{ $leave->created_at }} | +
+
+
+
+
+
-
+ 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 |
- |
+