StocksNew/Modules/Recruit/app/Http/Controllers/InterviewScheduleController.php

128 lines
3.7 KiB
PHP
Raw Permalink Normal View History

2024-08-27 12:03:06 +00:00
<?php
namespace Modules\Recruit\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Employee\Repositories\EmployeeRepository;
use Modules\Recruit\Repositories\InterviewScheduleInterface;
use Modules\Recruit\Repositories\InterviewScheduleRepository;
use Modules\Recruit\Repositories\JobPostInterface;
use Modules\Recruit\Repositories\JobPostRepository;
use Yoeunes\Toastr\Facades\Toastr;
class InterviewScheduleController extends Controller
{
private $interviewScheduleRepository;
private $jobPostRepository;
private $employeeRepository;
public function __construct(InterviewScheduleInterface $interviewScheduleRepository, JobPostInterface $jobPostRepository, EmployeeRepository $employeeRepository)
{
$this->interviewScheduleRepository = $interviewScheduleRepository;
$this->jobPostRepository = $jobPostRepository;
$this->employeeRepository = $employeeRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = 'Interview Schedule Lists';
$data['interviewScheduleLists'] = $this->interviewScheduleRepository->findAll();
return view('recruit::interviewschedules.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create InterviewSchedule';
$data['editable'] = false;
$data['jobPostLists'] = $this->jobPostRepository->pluck();
$data['employeeLists'] = $this->employeeRepository->pluck();
return view('recruit::interviewschedules.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
$request->merge([
'createdBy' => auth()->user()->id,
]);
try {
$this->interviewScheduleRepository->create($request->all());
toastr()->success('InterviewSchedule Created Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
// return redirect()->route('interviewSchedule.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('recruit::interviewschedules.show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit InterviewSchedule';
$data['editable'] = true;
$data['jobPostLists'] = $this->jobPostRepository->pluck();
$data['employeeLists'] = $this->employeeRepository->pluck();
$data['interviewSchedule'] = $this->interviewScheduleRepository->getInterviewScheduleById($id);
return view('recruit::interviewschedules.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
$inputData = $request->all();
try {
$this->interviewScheduleRepository->update($id, $inputData);
toastr()->success('InterviewSchecule Updated Succesfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('interviewSchedule.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$this->interviewScheduleRepository->delete($id);
toastr()->success('InterviewSchecule Deleted Succesfully');
} catch (\Throwable $th) {
//throw $th;
toastr()->error($th->getMessage());
}
}
}