Merge branch 'main' of http://bibgit.com/dharmaraj/New-OMIS into omis_dharma
This commit is contained in:
commit
e0fe321cb7
@ -3,18 +3,25 @@
|
|||||||
namespace Modules\Employee\Http\Controllers;
|
namespace Modules\Employee\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Role;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Modules\Employee\Repositories\EmployeeInterface;
|
use Modules\Employee\Repositories\EmployeeInterface;
|
||||||
|
use Modules\User\Repositories\UserInterface;
|
||||||
|
|
||||||
class EmployeeController extends Controller
|
class EmployeeController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
private EmployeeInterface $employeeRepository;
|
private $employeeRepository;
|
||||||
|
private $userRepository;
|
||||||
|
|
||||||
public function __construct(EmployeeInterface $employeeRepository)
|
public function __construct(EmployeeInterface $employeeRepository, UserInterface $userRepository)
|
||||||
{
|
{
|
||||||
$this->employeeRepository = $employeeRepository;
|
$this->employeeRepository = $employeeRepository;
|
||||||
|
$this->userRepository = $userRepository;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
@ -22,6 +29,8 @@ class EmployeeController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$data['employees'] = $this->employeeRepository->findAll();
|
$data['employees'] = $this->employeeRepository->findAll();
|
||||||
|
$data['roleLists'] = Role::pluck('name', 'id');
|
||||||
|
// dd($data['employees']->toArray());
|
||||||
return view('employee::index', $data);
|
return view('employee::index', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +40,11 @@ class EmployeeController extends Controller
|
|||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$data['title'] = 'Create Employee';
|
$data['title'] = 'Create Employee';
|
||||||
|
$data['departmentList'] = [];
|
||||||
|
$data['designationList'] = [];
|
||||||
|
$data['genderList'] = [];
|
||||||
|
$data['nationalityList'] = [];
|
||||||
|
|
||||||
return view('employee::create', $data);
|
return view('employee::create', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,22 +53,20 @@ class EmployeeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$inputData = $request->only(['first_name', 'last_name']);
|
$inputData = $request->all();
|
||||||
// try {
|
try {
|
||||||
|
|
||||||
if ($request->hasFile('profile_pic')) {
|
if ($request->hasFile('profile_pic')) {
|
||||||
$fileName = time() . '_' . $request->profile_pic->getClientOriginalName();
|
$fileName = time() . '_' . $request->profile_pic->getClientOriginalName();
|
||||||
$filePath = $request->file('profile_pic')->storeAs('uploads', $fileName, 'public');
|
$filePath = $request->file('profile_pic')->storeAs('uploads', $fileName, 'public');
|
||||||
$inputData['profile_picture'] = time() . '_' . $request->profile_pic->getClientOriginalName();
|
$inputData['profile_picture'] = time() . '_' . $request->profile_pic->getClientOriginalName();
|
||||||
// $fileModel->file_path = '/storage/' . $filePath;
|
}
|
||||||
// $fileModel->save();
|
|
||||||
|
$this->employeeRepository->create($inputData);
|
||||||
|
toastr()->success('Employee Created Succesfully');
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
toastr()->error($th->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->employeeRepository->create($inputData);
|
|
||||||
toastr()->success('Employee Created Succesfully');
|
|
||||||
// } catch (\Throwable $th) {
|
|
||||||
// toastr()->error($th->getMessage());
|
|
||||||
// }
|
|
||||||
return redirect()->route('employee.index');
|
return redirect()->route('employee.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,8 +75,8 @@ class EmployeeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
|
$data['employee'] = $this->employeeRepository->getEmployeeById($id);
|
||||||
return view('employee::show');
|
return view('employee::show', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,20 +94,20 @@ class EmployeeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(Request $request, $id): RedirectResponse
|
public function update(Request $request, $id): RedirectResponse
|
||||||
{
|
{
|
||||||
$inputData = $request->only(['first_name', 'last_name']);
|
$inputData = $request->except(['_method', '_token']);
|
||||||
// try {
|
try {
|
||||||
|
|
||||||
if ($request->hasFile('profile_pic')) {
|
if ($request->hasFile('profile_pic')) {
|
||||||
$fileName = time() . '_' . $request->profile_pic->getClientOriginalName();
|
$fileName = time() . '_' . $request->profile_pic->getClientOriginalName();
|
||||||
$filePath = $request->file('profile_pic')->storeAs('uploads', $fileName, 'public');
|
$filePath = $request->file('profile_pic')->storeAs('uploads', $fileName, 'public');
|
||||||
$inputData['profile_picture'] = time() . '_' . $request->profile_pic->getClientOriginalName();
|
$inputData['profile_picture'] = time() . '_' . $request->profile_pic->getClientOriginalName();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->employeeRepository->update($id, $inputData);
|
||||||
|
toastr()->success('Employee Created Succesfully');
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
toastr()->error($th->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->employeeRepository->update($id, $inputData);
|
|
||||||
toastr()->success('Employee Created Succesfully');
|
|
||||||
// } catch (\Throwable $th) {
|
|
||||||
// toastr()->error($th->getMessage());
|
|
||||||
// }
|
|
||||||
return redirect()->route('employee.index');
|
return redirect()->route('employee.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +116,41 @@ class EmployeeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
//
|
try {
|
||||||
|
$employeeModel = $this->employeeRepository->getEmployeeById($id);
|
||||||
|
$employeeModel->user->roles()->detach();
|
||||||
|
$employeeModel->user->delete();
|
||||||
|
$employeeModel->delete();
|
||||||
|
toastr()->success('Employee Delete Succesfully');
|
||||||
|
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
toastr()->error($th->getMessage());
|
||||||
|
}
|
||||||
|
return redirect()->route('employee.index');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assignRole(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$employeeModel = $this->employeeRepository->getEmployeeByEmail($request->email);
|
||||||
|
|
||||||
|
$inputData = [
|
||||||
|
'name' => $employeeModel->first_name . ' ' . $employeeModel->last_name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make('password'),
|
||||||
|
'email_verified_at' => Carbon::now(),
|
||||||
|
];
|
||||||
|
$userModel = $this->userRepository->create($inputData, [$request->role_id]);
|
||||||
|
|
||||||
|
$employeeModel->users_id = $userModel->id;
|
||||||
|
$employeeModel->save();
|
||||||
|
|
||||||
|
toastr()->success('Role Assigned Succesfully');
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
toastr()->error($th->getMessage());
|
||||||
|
}
|
||||||
|
return redirect()->route('employee.index');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Modules\Employee\Models;
|
namespace Modules\Employee\Models;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Employee extends Model
|
class Employee extends Model
|
||||||
@ -10,4 +11,8 @@ class Employee extends Model
|
|||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'users_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ interface EmployeeInterface
|
|||||||
{
|
{
|
||||||
public function findAll();
|
public function findAll();
|
||||||
public function getEmployeeById($employeeId);
|
public function getEmployeeById($employeeId);
|
||||||
|
public function getEmployeeByEmail($email);
|
||||||
public function delete($employeeId);
|
public function delete($employeeId);
|
||||||
public function create($EmployeeDetails);
|
public function create($EmployeeDetails);
|
||||||
public function update($employeeId, array $newDetails);
|
public function update($employeeId, array $newDetails);
|
||||||
|
@ -8,7 +8,7 @@ class EmployeeRepository implements EmployeeInterface
|
|||||||
{
|
{
|
||||||
public function findAll()
|
public function findAll()
|
||||||
{
|
{
|
||||||
return Employee::get();
|
return Employee::with('user.roles')->paginate(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmployeeById($employeeId)
|
public function getEmployeeById($employeeId)
|
||||||
@ -16,6 +16,11 @@ class EmployeeRepository implements EmployeeInterface
|
|||||||
return Employee::findOrFail($employeeId);
|
return Employee::findOrFail($employeeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getEmployeeByEmail($email)
|
||||||
|
{
|
||||||
|
return Employee::where('email', $email)->first();
|
||||||
|
}
|
||||||
|
|
||||||
public function delete($employeeId)
|
public function delete($employeeId)
|
||||||
{
|
{
|
||||||
Employee::destroy($employeeId);
|
Employee::destroy($employeeId);
|
||||||
@ -23,7 +28,6 @@ class EmployeeRepository implements EmployeeInterface
|
|||||||
|
|
||||||
public function create($employeeDetails)
|
public function create($employeeDetails)
|
||||||
{
|
{
|
||||||
// dd($employeeDetails);
|
|
||||||
return Employee::create($employeeDetails);
|
return Employee::create($employeeDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,36 +17,23 @@ return new class extends Migration
|
|||||||
$table->string('middle_name')->nullable();
|
$table->string('middle_name')->nullable();
|
||||||
$table->string('last_name')->nullable();
|
$table->string('last_name')->nullable();
|
||||||
$table->string('email')->nullable();
|
$table->string('email')->nullable();
|
||||||
$table->unsignedBigInteger('genders_id')->nullable();
|
|
||||||
$table->date('nepali_dob')->nullable();
|
$table->date('nepali_dob')->nullable();
|
||||||
$table->date('dob')->nullable();
|
$table->date('dob')->nullable();
|
||||||
$table->unsignedBigInteger('nationalities_id')->nullable();
|
|
||||||
$table->text('about_me')->nullable();
|
|
||||||
$table->string('signature')->nullable();
|
$table->string('signature')->nullable();
|
||||||
$table->string('father_name')->nullable();
|
$table->string('father_name')->nullable();
|
||||||
$table->string('mother_name')->nullable();
|
|
||||||
$table->string('grand_father_name')->nullable();
|
|
||||||
$table->string('grand_mother_name')->nullable();
|
|
||||||
$table->string('spouse')->nullable();
|
|
||||||
$table->string('contact')->nullable();
|
$table->string('contact')->nullable();
|
||||||
$table->string('alt_contact')->nullable();
|
|
||||||
$table->string('profile_picture')->nullable();
|
$table->string('profile_picture')->nullable();
|
||||||
|
$table->unsignedBigInteger('genders_id')->nullable();
|
||||||
|
$table->unsignedBigInteger('nationalities_id')->nullable();
|
||||||
$table->unsignedBigInteger('users_id')->nullable();
|
$table->unsignedBigInteger('users_id')->nullable();
|
||||||
$table->text('skills')->nullable();
|
$table->integer('is_user_assigned')->nullable()->default(10);
|
||||||
$table->text('experience')->nullable();
|
$table->unsignedBigInteger('organization_id')->nullable();
|
||||||
|
$table->unsignedBigInteger('department_id')->nullable();
|
||||||
|
$table->unsignedBigInteger('designation_id')->nullable();
|
||||||
$table->text('permanent_address')->nullable();
|
$table->text('permanent_address')->nullable();
|
||||||
$table->unsignedBigInteger('permanent_city')->nullable();
|
|
||||||
$table->text('temporary_address')->nullable();
|
$table->text('temporary_address')->nullable();
|
||||||
$table->unsignedBigInteger('temporary_city')->nullable();
|
$table->string('status')->nullable()->default(11);
|
||||||
$table->text('old_system_address')->nullable();
|
|
||||||
$table->text('education')->nullable();
|
|
||||||
$table->unsignedBigInteger('castes_id')->nullable();
|
|
||||||
$table->unsignedBigInteger('ethnicities_id')->nullable();
|
|
||||||
$table->unsignedBigInteger('dags_id')->nullable();
|
|
||||||
$table->string('status')->nullable();
|
|
||||||
$table->string('remarks')->nullable();
|
$table->string('remarks')->nullable();
|
||||||
$table->unsignedBigInteger('createdby')->nullable();
|
|
||||||
$table->unsignedBigInteger('updatedby')->nullable();
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,28 @@
|
|||||||
<div class="team-cover"> <img src="assets/images/small/img-9.jpg" alt="" class="img-fluid">
|
<div class="team-cover"> <img src="assets/images/small/img-9.jpg" alt="" class="img-fluid">
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
<div class="ribbon-two ribbon-two-success"><span>Active</span></div>
|
@if ($employee->user)
|
||||||
|
<div class="ribbon-two ribbon-two-success">
|
||||||
|
<span>{{ optional($employee->user)->getRoleNames()->first() }}</span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
<div class="row align-items-center team-row">
|
<div class="row align-items-center team-row">
|
||||||
|
<div class="col team-settings">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
</div>
|
||||||
|
<div class="col dropdown text-end"> <a href="javascript:void(0);" data-bs-toggle="dropdown"
|
||||||
|
aria-expanded="false" class=""> <i class="ri-more-fill fs-17"></i> </a>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-end" style="">
|
||||||
|
<li><a class="dropdown-item remove-item-btn" href="javascript:void(0);"
|
||||||
|
data-link="{{ route('employee.destroy', $employee->id) }}"
|
||||||
|
data-id="{{ $employee->id }}"><i
|
||||||
|
class="ri-delete-bin-5-line text-muted me-2 align-bottom"></i>Delete</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-4 col">
|
<div class="col-lg-4 col">
|
||||||
<div class="team-profile-img">
|
<div class="team-profile-img">
|
||||||
<div class="avatar-lg img-thumbnail rounded-circle flex-shrink-0"><img
|
<div class="avatar-lg img-thumbnail rounded-circle flex-shrink-0"><img
|
||||||
@ -82,6 +102,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="list-inline-item avatar-xs">
|
<li class="list-inline-item avatar-xs">
|
||||||
<a href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#assignRoleModal"
|
<a href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#assignRoleModal"
|
||||||
|
data-email="{{ $employee->email }}"
|
||||||
class="avatar-title bg-primary-subtle text-primary fs-15 rounded">
|
class="avatar-title bg-primary-subtle text-primary fs-15 rounded">
|
||||||
<i class="ri-user-add-line"></i>
|
<i class="ri-user-add-line"></i>
|
||||||
</a>
|
</a>
|
||||||
@ -100,6 +121,13 @@
|
|||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-end align-self-end">
|
||||||
|
<div class="mt-2 p-2">
|
||||||
|
{{ $employees->links() }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -117,29 +145,31 @@
|
|||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form action="{{ route('leave.store') }}" class="needs-validation" novalidate method="post">
|
{{ html()->form('POST')->route('employee.assignRole')->class(['needs-validation'])->attributes(['novalidate'])->open() }}
|
||||||
<div class="row gy-2">
|
<div class="row gy-2">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
{{ html()->label('Username')->class('form-label') }}
|
{{ html()->label('Email')->class('form-label') }}
|
||||||
{{ html()->text('username')->class('form-control')->placeholder('Enter Username')->required() }}
|
{{ html()->email('email')->class('form-control email-field')->placeholder('Enter Email')->isReadonly(true)->required() }}
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-lg-12">
|
|
||||||
{{ html()->label('Role')->class('form-label') }}
|
|
||||||
{{ html()->select('role_id', [])->class('form-select')->placeholder('Select Role')->required() }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-4 text-end">
|
<div class="col-lg-12">
|
||||||
<button type="submit" class="btn btn-success w-sm">Save</button>
|
{{ html()->label('Role')->class('form-label') }}
|
||||||
|
{{ html()->select('role_id', $roleLists)->class('form-select')->placeholder('Select Role')->required() }}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4 text-end">
|
||||||
|
<button type="submit" class="btn btn-success w-sm">Save</button>
|
||||||
|
</div>
|
||||||
|
{{ html()->form()->close() }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal fade" id="changePasswordModal" tabindex="-1" aria-labelledby="changePasswordLabel" aria-modal="true">
|
<div class="modal fade" id="changePasswordModal" tabindex="-1" aria-labelledby="changePasswordLabel"
|
||||||
|
aria-modal="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header model-primary">
|
<div class="modal-header model-primary">
|
||||||
@ -170,3 +200,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@push('js')
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#assignRoleModal').on('shown.bs.modal', function(e) {
|
||||||
|
// do something...
|
||||||
|
var email = $(e.relatedTarget).data('email');
|
||||||
|
$('.email-field').val(email)
|
||||||
|
console.log(email);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
@ -1,144 +1,121 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header card-primary">
|
{{-- <div class="card-header card-primary">
|
||||||
<h4 class="card-title mb-0">Personal Details</h4>
|
<h4 class="card-title mb-0">Personal Details</h4>
|
||||||
</div>
|
</div> --}}
|
||||||
|
|
||||||
<div class="card-body row gy-4">
|
<div class="card-body">
|
||||||
|
<div class="row gy-1">
|
||||||
|
<p class="text-primary">Personal Details</p>
|
||||||
|
<hr>
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('First name')->class('form-label') }}
|
||||||
|
{{ html()->text('first_name')->class('form-control')->placeholder('Enter First Name')->required() }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{{ html()->label('First name')->class('form-label') }}
|
{{ html()->label('Middle name')->class('form-label') }}
|
||||||
{{ html()->text('first_name')->class('form-control')->placeholder('Enter First Name')->required() }}
|
{{ html()->text('middle_name')->class('form-control')->placeholder('Enter Middle Name') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{{ html()->label('Middle name')->class('form-label') }}
|
{{ html()->label('Last name')->class('form-label') }}
|
||||||
{{ html()->text('middle_name')->class('form-control')->placeholder('Enter Middle Name') }}
|
{{ html()->text('last_name')->class('form-control')->placeholder('Enter Last Name')->required() }}
|
||||||
</div>
|
{{ html()->div('Please enter last name')->class('invalid-feedback') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{{ html()->label('Last name')->class('form-label') }}
|
{{ html()->label('Gender')->class('form-label') }}
|
||||||
{{ html()->text('last_name')->class('form-control')->placeholder('Enter Last Name')->required() }}
|
{{ html()->select('genders_id', [1 => 'male', 2 => 'female'])->class('form-select')->placeholder('Select Gender') }}
|
||||||
{{ html()->div('Please enter last name')->class('invalid-feedback') }}
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{{ html()->label('Gender')->class('form-label') }}
|
{{ html()->label('Date of Birth')->class('form-label') }}
|
||||||
{{ html()->select('gender', ['male', 'female'])->class('form-select')->placeholder('Select Gender') }}
|
{{ html()->date('dob')->class('form-control')->placeholder('Choose Date of Birth')->required() }}
|
||||||
</div>
|
{{ html()->div('Please choose dob')->class('invalid-feedback') }}
|
||||||
|
|
||||||
<div class="col-md-4">
|
</div>
|
||||||
{{ html()->label('Date of Birth')->class('form-label') }}
|
|
||||||
{{ html()->date('dob')->class('form-control')->placeholder('Choose Date of Birth')->required() }}
|
<div class="col-md-4">
|
||||||
{{ html()->div('Please choose dob')->class('invalid-feedback') }}
|
{{ html()->label('Nationality')->class('form-label') }}
|
||||||
|
{{ html()->select('nationalities_id', [1 => 'Nepal', 2 => 'Other'])->class('form-control')->placeholder('Select Nationality') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Email')->class('form-label') }}
|
||||||
|
{{ html()->email('email')->class('form-control')->placeholder('Enter Email')->required() }}
|
||||||
|
{{ html()->div('Please enter email')->class('invalid-feedback') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Phone Number')->class('form-label') }}
|
||||||
|
{{ html()->text('contact')->class('form-control')->placeholder('Enter Phone Number') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Upload Profile Pic')->class('form-label') }}
|
||||||
|
{{ html()->file('profile_pic')->class('form-control') }}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="row gy-1 mt-1">
|
||||||
{{ html()->label('Nationality')->class('form-label') }}
|
<p class="text-primary">Address Details</p>
|
||||||
{{ html()->select('nationality', ['Nepal', 'Other'])->class('form-control')->placeholder('Select Nationality') }}
|
<hr>
|
||||||
|
|
||||||
|
{{-- <div class="col-md-4">
|
||||||
|
{{ html()->label('Municipality')->class('form-label') }}
|
||||||
|
{{ html()->select('municipality_id', [])->class('form-select')->placeholder('Select Municipality') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Ward')->class('form-label') }}
|
||||||
|
{{ html()->text('ward')->class('form-control')->placeholder('Enter Ward no') }}
|
||||||
|
</div> --}}
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Permanent Address')->class('form-label') }}
|
||||||
|
{{ html()->text('permanent_address')->class('form-control')->placeholder('Enter Permanent Address') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Temporary Address')->class('form-label') }}
|
||||||
|
{{ html()->text('temporary_address')->class('form-control')->placeholder('Enter Temporary Address') }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="row gy-1 mt-1">
|
||||||
{{ html()->label('Email')->class('form-label') }}
|
<p class="text-primary">Organization Details</p>
|
||||||
{{ html()->email('email')->class('form-control')->placeholder('Enter Email')->required() }}
|
<hr>
|
||||||
{{ html()->div('Please enter email')->class('invalid-feedback') }}
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Department')->class('form-label') }}
|
||||||
|
{{ html()->select('department_id', ['Nepal'])->class('form-select')->placeholder('Select Department') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Designation')->class('form-label') }}
|
||||||
|
{{ html()->select('designation_id', ['Nepal'])->class('form-select')->placeholder('Select Designation') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- <div class="col-md-4">
|
||||||
|
{{ html()->label('Join Date')->class('form-label') }}
|
||||||
|
{{ html()->date('join_date')->class('form-control')->placeholder('Choose Join Date') }}
|
||||||
|
</div> --}}
|
||||||
|
|
||||||
|
|
||||||
|
<div class="col-md-8">
|
||||||
|
{{ html()->label('Remarks')->class('form-label') }}
|
||||||
|
{{ html()->textarea('remarks')->class('form-control')->placeholder('Enter Remarks') }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('Phone Number')->class('form-label') }}
|
|
||||||
{{ html()->text('phone')->class('form-control')->placeholder('Enter Phone Number') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('Upload Profile Pic')->class('form-label') }}
|
|
||||||
{{ html()->file('profile_pic')->class('form-control') }}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- end card body -->
|
<!-- end card body -->
|
||||||
</div>
|
</div>
|
||||||
<!-- end card -->
|
<!-- end card -->
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header card-primary">
|
|
||||||
<h5 class="card-title mb-0">Address Detail</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body row gy-2">
|
|
||||||
{{-- <div class="col-md-4">
|
|
||||||
{{ html()->label('Country')->class('form-label') }}
|
|
||||||
{{ html()->select('country_id', ['Nepal'])->class('form-select')->placeholder('Select Country') }}
|
|
||||||
</div> --}}
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('State')->class('form-label') }}
|
|
||||||
{{ html()->select('state_id', ['Nepal'])->class('form-select')->placeholder('Select State') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('District name')->class('form-label') }}
|
|
||||||
{{ html()->select('district_id', [])->class('form-select')->placeholder('Select District') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('City')->class('form-label') }}
|
|
||||||
{{ html()->text('last_name')->class('form-control')->placeholder('Enter City Name') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('municipality')->class('form-label') }}
|
|
||||||
{{ html()->select('municipality_id', [])->class('form-select')->placeholder('Select Municipality') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('Ward')->class('form-label') }}
|
|
||||||
{{ html()->text('ward')->class('form-control')->placeholder('Enter Ward no') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('Permanent Address')->class('form-label') }}
|
|
||||||
{{ html()->text('perm_address')->class('form-control')->placeholder('Enter Permanent Address') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('Temporary Address')->class('form-label') }}
|
|
||||||
{{ html()->text('temp_address')->class('form-control')->placeholder('Enter Temporary Address') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header card-primary">
|
|
||||||
<h5 class="card-title mb-0">Organization Detail</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card-body row gy-2">
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('Department')->class('form-label') }}
|
|
||||||
{{ html()->select('department_id', ['Nepal'])->class('form-select')->placeholder('Select Department') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('Designation')->class('form-label') }}
|
|
||||||
{{ html()->select('designation_id', ['Nepal'])->class('form-select')->placeholder('Select Designation') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{ html()->label('Join Date')->class('form-label') }}
|
|
||||||
{{ html()->date('join_date')->class('form-control')->placeholder('Choose Join Date') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-8">
|
|
||||||
{{ html()->label('Remarks')->class('form-label') }}
|
|
||||||
{{ html()->textarea('remark')->class('form-control')->placeholder('Enter Remarks') }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- end card -->
|
|
||||||
<div class="mb-4 text-end">
|
<div class="mb-4 text-end">
|
||||||
<button type="submit" class="btn btn-success w-sm">Save</button>
|
<button type="submit" class="btn btn-success w-sm">Save</button>
|
||||||
</div>
|
</div>
|
||||||
|
128
Modules/Employee/resources/views/partials/action.blade.php.bak
Normal file
128
Modules/Employee/resources/views/partials/action.blade.php.bak
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header card-primary">
|
||||||
|
<h4 class="card-title mb-0">Personal Details</h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body row gy-4">
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('First name')->class('form-label') }}
|
||||||
|
{{ html()->text('first_name')->class('form-control')->placeholder('Enter First Name')->required() }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Middle name')->class('form-label') }}
|
||||||
|
{{ html()->text('middle_name')->class('form-control')->placeholder('Enter Middle Name') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Last name')->class('form-label') }}
|
||||||
|
{{ html()->text('last_name')->class('form-control')->placeholder('Enter Last Name')->required() }}
|
||||||
|
{{ html()->div('Please enter last name')->class('invalid-feedback') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Gender')->class('form-label') }}
|
||||||
|
{{ html()->select('gender', ['male', 'female'])->class('form-select')->placeholder('Select Gender') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Date of Birth')->class('form-label') }}
|
||||||
|
{{ html()->date('dob')->class('form-control')->placeholder('Choose Date of Birth')->required() }}
|
||||||
|
{{ html()->div('Please choose dob')->class('invalid-feedback') }}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Nationality')->class('form-label') }}
|
||||||
|
{{ html()->select('nationality', ['Nepal', 'Other'])->class('form-control')->placeholder('Select Nationality') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Email')->class('form-label') }}
|
||||||
|
{{ html()->email('email')->class('form-control')->placeholder('Enter Email')->required() }}
|
||||||
|
{{ html()->div('Please enter email')->class('invalid-feedback') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Phone Number')->class('form-label') }}
|
||||||
|
{{ html()->text('phone')->class('form-control')->placeholder('Enter Phone Number') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Upload Profile Pic')->class('form-label') }}
|
||||||
|
{{ html()->file('profile_pic')->class('form-control') }}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- end card body -->
|
||||||
|
</div>
|
||||||
|
<!-- end card -->
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header card-primary">
|
||||||
|
<h5 class="card-title mb-0">Address Detail</h5>
|
||||||
|
</div>
|
||||||
|
<div class="card-body row gy-2">
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Municipality')->class('form-label') }}
|
||||||
|
{{ html()->select('municipality_id', [])->class('form-select')->placeholder('Select Municipality') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Ward')->class('form-label') }}
|
||||||
|
{{ html()->text('ward')->class('form-control')->placeholder('Enter Ward no') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Permanent Address')->class('form-label') }}
|
||||||
|
{{ html()->text('perm_address')->class('form-control')->placeholder('Enter Permanent Address') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Temporary Address')->class('form-label') }}
|
||||||
|
{{ html()->text('temp_address')->class('form-control')->placeholder('Enter Temporary Address') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header card-primary">
|
||||||
|
<h5 class="card-title mb-0">Organization Detail</h5>
|
||||||
|
</div>
|
||||||
|
<div class="card-body row gy-2">
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Department')->class('form-label') }}
|
||||||
|
{{ html()->select('department_id', ['Nepal'])->class('form-select')->placeholder('Select Department') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Designation')->class('form-label') }}
|
||||||
|
{{ html()->select('designation_id', ['Nepal'])->class('form-select')->placeholder('Select Designation') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ html()->label('Join Date')->class('form-label') }}
|
||||||
|
{{ html()->date('join_date')->class('form-control')->placeholder('Choose Join Date') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="col-md-8">
|
||||||
|
{{ html()->label('Remarks')->class('form-label') }}
|
||||||
|
{{ html()->textarea('remark')->class('form-control')->placeholder('Enter Remarks') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- end card -->
|
||||||
|
<div class="mb-4 text-end">
|
||||||
|
<button type="submit" class="btn btn-success w-sm">Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
@ -12,8 +12,12 @@ use Modules\Employee\Http\Controllers\EmployeeController;
|
|||||||
| routes are loaded by the RouteServiceProvider within a group which
|
| routes are loaded by the RouteServiceProvider within a group which
|
||||||
| contains the "web" middleware group. Now create something great!
|
| contains the "web" middleware group. Now create something great!
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Route::group([], function () {
|
Route::group(['middleware' => 'auth'], function () {
|
||||||
|
Route::post('assignRole', [EmployeeController::class, 'assignRole'])->name('employee.assignRole');
|
||||||
Route::resource('employee', EmployeeController::class)->names('employee');
|
Route::resource('employee', EmployeeController::class)->names('employee');
|
||||||
|
Route::group(['prefix' => 'employee'], function () {
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -24,7 +24,8 @@ class UserRepository implements UserInterface
|
|||||||
public function create(array $userDetails, array $role)
|
public function create(array $userDetails, array $role)
|
||||||
{
|
{
|
||||||
$user = User::create($userDetails);
|
$user = User::create($userDetails);
|
||||||
return $user->roles()->attach($role);
|
$user->roles()->attach($role);
|
||||||
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($userId, array $newDetails)
|
public function update($userId, array $newDetails)
|
||||||
|
@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Laravel\Sanctum\HasApiTokens;
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
|
use Modules\Employee\Models\Employee;
|
||||||
use Spatie\Permission\Traits\HasRoles;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
@ -45,7 +46,8 @@ class User extends Authenticatable
|
|||||||
'email_verified_at' => 'datetime',
|
'email_verified_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
// public function employee(){
|
public function employee()
|
||||||
// return $this->belongsTo(Employee::class,'employee_id');
|
{
|
||||||
// }
|
return $this->hasOne(Employee::class, 'users_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Pagination\Paginator;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
@ -20,5 +21,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
Paginator::useBootstrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
app/Service/DepartmentService.php
Normal file
33
app/Service/DepartmentService.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Department\Repositories;
|
||||||
|
|
||||||
|
use Modules\Department\Models\Department;
|
||||||
|
|
||||||
|
class DepartmentService
|
||||||
|
{
|
||||||
|
public function findAll()
|
||||||
|
{
|
||||||
|
return Department::paginate(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDepartmentById($DepartmentId)
|
||||||
|
{
|
||||||
|
return Department::findOrFail($DepartmentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($DepartmentId)
|
||||||
|
{
|
||||||
|
Department::destroy($DepartmentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create($DepartmentDetails)
|
||||||
|
{
|
||||||
|
return Department::create($DepartmentDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update($DepartmentId, array $newDetails)
|
||||||
|
{
|
||||||
|
return Department::whereId($DepartmentId)->update($newDetails);
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
$('body').on('click', '.remove-item-btn', function (e) {
|
$('body').on('click', '.remove-item-btn', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let url = $(this).data('link');
|
let url = $(this).data('link');
|
||||||
let id = $(this).data('id');
|
let id = $(this).data('id');
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Are you sure?',
|
title: 'Are you sure?',
|
||||||
|
Loading…
Reference in New Issue
Block a user