From 91e7943546f32edbce0ed5b69158039786236476 Mon Sep 17 00:00:00 2001 From: Ranjan Date: Thu, 11 Apr 2024 16:37:12 +0545 Subject: [PATCH] employee module --- Modules/Employee/app/Models/Employee.php | 6 + .../app/Repositories/EmployeeInterface.php | 2 + .../app/Repositories/EmployeeRepository.php | 7 +- Modules/Employee/routes/web.php | 2 + .../app/Http/Controllers/LeaveController.php | 20 +- Modules/Leave/resources/views/edit.blade.php | 2 +- .../resources/views/partials/action.blade.php | 3 +- resources/views/invoice.blade.php | 385 ++++++++++++++++++ routes/web.php | 4 + 9 files changed, 417 insertions(+), 14 deletions(-) create mode 100644 resources/views/invoice.blade.php diff --git a/Modules/Employee/app/Models/Employee.php b/Modules/Employee/app/Models/Employee.php index 71d31d3..076c097 100644 --- a/Modules/Employee/app/Models/Employee.php +++ b/Modules/Employee/app/Models/Employee.php @@ -10,6 +10,12 @@ class Employee extends Model protected $table = 'tbl_employees'; protected $primaryKey = 'id'; protected $guarded = []; + protected $appends = (['full_name']); + + protected function getFullNameAttribute() + { + return $this->first_name . ' ' . $this->middle_name . ' ' . $this->last_name; + } public function user() { diff --git a/Modules/Employee/app/Repositories/EmployeeInterface.php b/Modules/Employee/app/Repositories/EmployeeInterface.php index e31844d..4f80cb3 100644 --- a/Modules/Employee/app/Repositories/EmployeeInterface.php +++ b/Modules/Employee/app/Repositories/EmployeeInterface.php @@ -10,4 +10,6 @@ interface EmployeeInterface public function delete($employeeId); public function create($EmployeeDetails); public function update($employeeId, array $newDetails); + public function pluck(); + } diff --git a/Modules/Employee/app/Repositories/EmployeeRepository.php b/Modules/Employee/app/Repositories/EmployeeRepository.php index ee32a5e..d244e2d 100644 --- a/Modules/Employee/app/Repositories/EmployeeRepository.php +++ b/Modules/Employee/app/Repositories/EmployeeRepository.php @@ -8,7 +8,7 @@ class EmployeeRepository implements EmployeeInterface { public function findAll() { - return Employee::with('user.roles')->paginate(20); + return Employee::paginate(20); } public function getEmployeeById($employeeId) @@ -36,6 +36,11 @@ class EmployeeRepository implements EmployeeInterface return Employee::whereId($employeeId)->update($newDetails); } + public function pluck() + { + return Employee::pluck('first_name', 'id'); + } + // public function uploadImage($file) // { // if ($req->file()) { diff --git a/Modules/Employee/routes/web.php b/Modules/Employee/routes/web.php index 45acc1c..0ffff23 100644 --- a/Modules/Employee/routes/web.php +++ b/Modules/Employee/routes/web.php @@ -21,3 +21,5 @@ Route::group(['middleware' => 'auth'], function () { }); }); + + diff --git a/Modules/Leave/app/Http/Controllers/LeaveController.php b/Modules/Leave/app/Http/Controllers/LeaveController.php index 92e4447..236e547 100644 --- a/Modules/Leave/app/Http/Controllers/LeaveController.php +++ b/Modules/Leave/app/Http/Controllers/LeaveController.php @@ -5,16 +5,19 @@ namespace Modules\Leave\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Modules\Employee\Repositories\EmployeeInterface; use Modules\Leave\Repositories\LeaveInterface; use Yoeunes\Toastr\Facades\Toastr; class LeaveController extends Controller { - private LeaveInterface $leaveRepository; + private $leaveRepository; + private $employeeRepository; - public function __construct(LeaveInterface $leaveRepository) + public function __construct(LeaveInterface $leaveRepository, EmployeeInterface $employeeRepository) { $this->leaveRepository = $leaveRepository; + $this->employeeRepository = $employeeRepository; $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']]); @@ -29,8 +32,9 @@ class LeaveController extends Controller public function index() { $data['leaves'] = $this->leaveRepository->findAll(); - - return view('leave::index',$data); + $data['employeeList'] = $this->employeeRepository->pluck(); + + return view('leave::index', $data); } /** @@ -39,7 +43,7 @@ class LeaveController extends Controller public function create() { $data['title'] = 'Create Leave'; - + $data['employeeList'] = $this->employeeRepository->pluck(); return view('leave::create', $data); } @@ -49,13 +53,9 @@ class LeaveController extends Controller 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()); } @@ -79,7 +79,7 @@ class LeaveController extends Controller $data['leave'] = $this->leaveRepository->getLeaveById($id); - return view('leave::edit',$data); + return view('leave::edit', $data); } /** diff --git a/Modules/Leave/resources/views/edit.blade.php b/Modules/Leave/resources/views/edit.blade.php index 37dd0f4..4644d7c 100644 --- a/Modules/Leave/resources/views/edit.blade.php +++ b/Modules/Leave/resources/views/edit.blade.php @@ -24,7 +24,7 @@
- + {{ html()->modelForm($leave, 'PUT')->route('leave.update', $leave->id)->class(['needs-validation'])->attributes(['novalidate'])->open() }} @include('leave::partials.action') diff --git a/Modules/Leave/resources/views/partials/action.blade.php b/Modules/Leave/resources/views/partials/action.blade.php index cedca0c..50e04e8 100644 --- a/Modules/Leave/resources/views/partials/action.blade.php +++ b/Modules/Leave/resources/views/partials/action.blade.php @@ -1,8 +1,7 @@
- + {{ html()->select('employee_id', $employeeList)->class('form-select')->placeholder('Select Employee') }}
diff --git a/resources/views/invoice.blade.php b/resources/views/invoice.blade.php new file mode 100644 index 0000000..53d6b08 --- /dev/null +++ b/resources/views/invoice.blade.php @@ -0,0 +1,385 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
+
+
+
+
+
+ + +
+
+
+ +
+
+ +
+ Please enter a address +
+
+
+ +
+ The US zip code must contain 5 digits, Ex. 45678 +
+
+
+
+ +
+
+ +
+ Please enter a registration no, Ex., 012345678912 +
+
+
+ +
+ Please enter a valid email, Ex., example@gamil.com +
+
+
+ +
+ Please enter a website, Ex., www.example.com +
+
+
+ +
+ Please enter a contact number +
+
+
+
+ +
+
+
+
+ + +
+ +
+
+ + +
+
+ +
+ +
+ +
+
+ +
+
+ + +
+
+ +
+ +
+
+
+
+
+ +
+
+ +
+ Please enter a full name +
+
+
+ +
+ Please enter a address +
+
+
+ +
+ Please enter a phone number +
+
+
+ +
+ Please enter a tax number +
+
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+ Please enter a full name +
+
+
+ +
+ Please enter a address +
+
+
+ +
+ Please enter a phone number +
+
+
+ +
+ Please enter a tax number +
+
+
+
+
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
# + Product Details + +
+ Rate + +
+
QuantityAmount
1 +
+ +
+ Please enter a product name +
+
+ +
+ +
+ Please enter a rate +
+
+
+ + + +
+
+
+ +
+
+ Delete +
+ Add Item +
+ + + + + + + + + + + + + + + + + + + + + + + +
Sub Total + +
Estimated Tax (12.5%) + +
Discount (VELZON15) + +
Shipping Charge + +
Total Amount + +
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ + +
+ +
+
+
+
+ +
+
+
+@endsection +@push('js') + +@endpush diff --git a/routes/web.php b/routes/web.php index 2a54685..914801f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -20,6 +20,10 @@ Route::get('/', function () { return view('welcome'); }); +Route::get('/invoice', function () { + return view('invoice'); +}); + Auth::routes(); Route::get('/dashboard', [App\Http\Controllers\HomeController::class, 'index'])->name('home');