110 lines
2.8 KiB
PHP
110 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\Admin\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use Modules\Admin\Repositories\WorkShiftRepository;
|
|
|
|
class WorkShiftController extends Controller
|
|
{
|
|
private $workShiftRepository;
|
|
|
|
public function __construct(WorkShiftRepository $workShiftRepository)
|
|
{
|
|
$this->workShiftRepository = $workShiftRepository;
|
|
}
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
$data['title'] = 'WorkShift Lists';
|
|
$data['workShiftLists'] = $this->workShiftRepository->findAll();
|
|
return view('admin::workshifts.index', $data);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
$data['title'] = 'Create WorkShift';
|
|
$data['editable'] = false;
|
|
return view('admin::workshifts.create', $data);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
try {
|
|
$this->workShiftRepository->create($request->all());
|
|
toastr()->success('WorkShift Created Successfully');
|
|
|
|
} catch (\Throwable $th) {
|
|
toastr()->error($th->getMessage());
|
|
}
|
|
return redirect()->route('workShift.index');
|
|
}
|
|
|
|
/**
|
|
* Show the specified resource.
|
|
*/
|
|
public function show($id)
|
|
{
|
|
return view('admin::workshifts.show');
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
try {
|
|
$data['title'] = 'Edit WorkShift';
|
|
$data['editable'] = true;
|
|
$data['workShift'] = $this->workShiftRepository->getWorkShiftById($id);
|
|
|
|
} catch (\Throwable $th) {
|
|
toastr()->error($th->getMessage());
|
|
}
|
|
|
|
return view('admin::workshifts.edit', $data);
|
|
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, $id): RedirectResponse
|
|
{
|
|
try {
|
|
|
|
$this->workShiftRepository->update($id, $request->all());
|
|
toastr()->success('WorkShift Updated Successfully');
|
|
|
|
} catch (\Throwable $th) {
|
|
toastr()->error($th->getMessage());
|
|
}
|
|
return redirect()->route('workShift.index');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
try {
|
|
$this->workShiftRepository->delete($id);
|
|
toastr()->success('WorkShift Deleted Successfully');
|
|
} catch (\Throwable $th) {
|
|
toastr()->error($th->getMessage());
|
|
}
|
|
return redirect()->route('workShift.index');
|
|
}
|
|
}
|