137 lines
3.8 KiB
PHP
137 lines
3.8 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\FieldRepository;
|
||
|
use Modules\Recruit\Repositories\JobApplicationInterface;
|
||
|
use Modules\Recruit\Repositories\JobApplicationRepository;
|
||
|
use Modules\Recruit\Repositories\JobPostInterface;
|
||
|
use Modules\Recruit\Repositories\JobPostRepository;
|
||
|
use Yoeunes\Toastr\Facades\Toastr;
|
||
|
|
||
|
class JobApplicationController extends Controller
|
||
|
{
|
||
|
private $jobApplicationRepository;
|
||
|
private $jobPostRepository;
|
||
|
|
||
|
private $fieldRepository;
|
||
|
|
||
|
public function __construct(JobApplicationInterface $jobApplicationRepository, JobPostInterface $jobPostRepository, FieldRepository $fieldRepository)
|
||
|
{
|
||
|
$this->jobApplicationRepository = $jobApplicationRepository;
|
||
|
$this->jobPostRepository = $jobPostRepository;
|
||
|
$this->fieldRepository = $fieldRepository;
|
||
|
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Display a listing of the resource.
|
||
|
*/
|
||
|
public function index()
|
||
|
{
|
||
|
$data['title'] = 'JobApplication Lists';
|
||
|
$data['jobApplicationLists'] = $this->jobApplicationRepository->findAll();
|
||
|
return view('recruit::jobapplications.index', $data);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Show the form for creating a new resource.
|
||
|
*/
|
||
|
public function create()
|
||
|
{
|
||
|
$data['title'] = 'Create JobApplication';
|
||
|
$data['editable'] = false;
|
||
|
$data['jobPostLists'] = $this->jobPostRepository->pluck();
|
||
|
$data['genderLists'] = $this->fieldRepository->getDropdownByAlias('gender');
|
||
|
return view('recruit::jobapplications.create', $data);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Store a newly created resource in storage.
|
||
|
*/
|
||
|
public function store(Request $request): RedirectResponse
|
||
|
{
|
||
|
$request->mergeIfMissing([
|
||
|
'createdBy' => auth()->user()->employee?->id,
|
||
|
'status' => 11,
|
||
|
|
||
|
]);
|
||
|
|
||
|
try {
|
||
|
$this->jobApplicationRepository->create($request->all());
|
||
|
toastr()->success('JobApplication Created Succesfully');
|
||
|
} catch (\Throwable $th) {
|
||
|
toastr()->error($th->getMessage());
|
||
|
}
|
||
|
return redirect()->route('jobApplication.index');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Show the specified resource.
|
||
|
*/
|
||
|
public function show($id)
|
||
|
{
|
||
|
return view('recruit::jobapplications.show');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Show the form for editing the specified resource.
|
||
|
*/
|
||
|
public function edit($id)
|
||
|
{
|
||
|
$data['title'] = 'Edit JobApplication';
|
||
|
|
||
|
$data['editable'] = true;
|
||
|
|
||
|
$data['jobPostLists'] = $this->jobPostRepository->pluck();
|
||
|
|
||
|
$data['genderLists'] = $this->fieldRepository->getDropdownByAlias('gender');
|
||
|
|
||
|
|
||
|
$data['jobApplication'] = $this->jobApplicationRepository->getJobApplicationById($id);
|
||
|
|
||
|
return view('recruit::jobapplications.edit', $data);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Update the specified resource in storage.
|
||
|
*/
|
||
|
public function update(Request $request, $id): RedirectResponse
|
||
|
{
|
||
|
$request->mergeIfMissing([
|
||
|
'updatedBy' => auth()->user()->employee?->id,
|
||
|
'status' => 11,
|
||
|
]);
|
||
|
|
||
|
$inputData = $request->all();
|
||
|
try {
|
||
|
|
||
|
$this->jobApplicationRepository->update($id, $inputData);
|
||
|
toastr()->success('JobApplication Updated Succesfully');
|
||
|
|
||
|
} catch (\Throwable $th) {
|
||
|
toastr()->error($th->getMessage());
|
||
|
}
|
||
|
return redirect()->route('jobApplication.index');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Remove the specified resource from storage.
|
||
|
*/
|
||
|
public function destroy($id)
|
||
|
{
|
||
|
try {
|
||
|
$this->jobApplicationRepository->delete($id);
|
||
|
|
||
|
toastr()->success('JobApplication Deleted Succesfully');
|
||
|
} catch (\Throwable $th) {
|
||
|
//throw $th;
|
||
|
toastr()->error($th->getMessage());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|