152 lines
5.0 KiB
PHP
152 lines
5.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\Recruit\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Modules\Admin\Repositories\DepartmentInterface;
|
|
use Modules\Admin\Repositories\DepartmentRepository;
|
|
use Modules\Admin\Repositories\DesignationRepository;
|
|
use Modules\Admin\Repositories\WorkShiftInterface;
|
|
use Modules\Admin\Repositories\WorkShiftRepository;
|
|
use Modules\Employee\Repositories\EmployeeInterface;
|
|
use Modules\Employee\Repositories\EmployeeRepository;
|
|
use Modules\Recruit\Repositories\JobApplicationInterface;
|
|
use Modules\Recruit\Repositories\JobPostInterface;
|
|
use Modules\Recruit\Repositories\OfferLetterInterface;
|
|
use Modules\Recruit\Repositories\OfferLetterRepository;
|
|
use Modules\Recruit\Repositories\JobPostRepository;
|
|
use Yoeunes\Toastr\Facades\Toastr;
|
|
|
|
class OfferLetterController extends Controller
|
|
{
|
|
private $offerLetterRepository;
|
|
private $departmentRepository;
|
|
private $designationRepository;
|
|
private $workShiftRepository;
|
|
private $employeeRepository;
|
|
private $jobPostRepository;
|
|
private $jobApplicationRepository;
|
|
|
|
public function __construct(OfferLetterInterface $offerLetterRepository, DepartmentInterface $departmentRepository, DesignationRepository $designationRepository, WorkShiftRepository $workShiftRepository, EmployeeInterface $employeeRepository, JobApplicationInterface $jobApplicationRepository, JobPostRepository $jobPostRepository)
|
|
{
|
|
$this->offerLetterRepository = $offerLetterRepository;
|
|
$this->departmentRepository = $departmentRepository;
|
|
$this->designationRepository = $designationRepository;
|
|
$this->workShiftRepository = $workShiftRepository;
|
|
$this->employeeRepository = $employeeRepository;
|
|
$this->jobPostRepository = $jobPostRepository;
|
|
$this->jobApplicationRepository = $jobApplicationRepository;
|
|
}
|
|
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
$data['title'] = 'OfferLetter Lists';
|
|
$data['offerLetterLists'] = $this->offerLetterRepository->findAll();
|
|
return view('recruit::offerletters.index', $data);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
$data['title'] = 'Create OfferLetter';
|
|
$data['editable'] = false;
|
|
$data['workShiftLists'] = $this->workShiftRepository->pluck();
|
|
$data['designationLists'] = $this->designationRepository->pluck();
|
|
$data['departmentLists'] = $this->departmentRepository->pluck();
|
|
$data['employeeLists'] = $this->employeeRepository->pluck();
|
|
$data['jobPostLists'] = $this->jobPostRepository->pluck();
|
|
$data['jobApplicationLists'] = $this->jobApplicationRepository->pluck();
|
|
$data['employeeLists'] = $this->employeeRepository->pluck();
|
|
|
|
return view('recruit::offerletters.create', $data);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$request->merge([
|
|
'createdBy' => auth()->user()->id,
|
|
]);
|
|
try {
|
|
$this->offerLetterRepository->create($request->all());
|
|
toastr()->success('OfferLetter Created Succesfully');
|
|
} catch (\Throwable $th) {
|
|
toastr()->error($th->getMessage());
|
|
}
|
|
|
|
return redirect()->route('offerLetter.index');
|
|
}
|
|
|
|
/**
|
|
* Show the specified resource.
|
|
*/
|
|
public function show($id)
|
|
{
|
|
return view('recruit::offerletters.show');
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
$data['title'] = 'Edit OfferLetter';
|
|
|
|
$data['editable'] = true;
|
|
|
|
$data['workShiftLists'] = $this->workShiftRepository->pluck();
|
|
|
|
$data['designationLists'] = $this->designationRepository->pluck();
|
|
|
|
$data['departmentLists'] = $this->departmentRepository->pluck();
|
|
|
|
$data['employeeLists'] = $this->employeeRepository->pluck();
|
|
|
|
$data['offerLetter'] = $this->offerLetterRepository->getOfferLetterById($id);
|
|
|
|
return view('recruit::offerletters.edit', $data);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, $id): RedirectResponse
|
|
{
|
|
$inputData = $request->all();
|
|
try {
|
|
|
|
$this->offerLetterRepository->update($id, $inputData);
|
|
toastr()->success('InterviewSchecule Updated Succesfully');
|
|
|
|
} catch (\Throwable $th) {
|
|
toastr()->error($th->getMessage());
|
|
}
|
|
return redirect()->route('offerLetter.index');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
try {
|
|
$this->offerLetterRepository->delete($id);
|
|
|
|
toastr()->success('OfferLetter Deleted Succesfully');
|
|
} catch (\Throwable $th) {
|
|
//throw $th;
|
|
toastr()->error($th->getMessage());
|
|
}
|
|
|
|
}
|
|
}
|