101 lines
2.6 KiB
PHP
101 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace Modules\Training\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use Modules\Employee\Repositories\EmployeeRepository;
|
|
use Modules\Training\Repositories\TrainerRepository;
|
|
|
|
class TrainerController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
private $employeeRepository;
|
|
private $trainerRepository;
|
|
|
|
|
|
|
|
public function __construct(TrainerRepository $trainerRepository, EmployeeRepository $employeeRepository ){
|
|
$this->employeeRepository = $employeeRepository;
|
|
$this->trainerRepository = $trainerRepository;
|
|
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$data['title'] = 'Trainer Lists';
|
|
$data['trainerLists'] = $this->trainerRepository->findAll();
|
|
|
|
return view ('training::trainer.index', $data);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
$data['title'] = 'Create Trainer';
|
|
$data['editable'] = false;
|
|
|
|
return view('training::trainer.create', $data);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$this->trainerRepository->create($request->all());
|
|
toastr()->success('Trainer Created Successfully');
|
|
return redirect()->route('trainer.index');
|
|
}
|
|
|
|
/**
|
|
* Show the specified resource.
|
|
*/
|
|
public function show($id)
|
|
{
|
|
$data['title'] = 'Training Details';
|
|
$data['item'] = $this->trainerRepository->getTrainerById($id);
|
|
return view('training::trainer.show', $data);
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
$data['title'] = 'Edit Leave';
|
|
$data['editable'] = true;
|
|
$data['trainer'] = $this->trainerRepository->getTrainerById($id);
|
|
return view('training::trainer.edit', $data);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, $id): RedirectResponse
|
|
{
|
|
$inputData = $request->all();
|
|
$this->trainerRepository->update($id, $inputData);
|
|
toastr()->success('Trainer Updated Succesfully');
|
|
|
|
return redirect()->route('trainer.index');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
$this->trainerRepository->delete($id);
|
|
toastr()->success('Trainer Deleted Succesfully');
|
|
}
|
|
}
|