101 lines
2.8 KiB
PHP
101 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 Modules\Admin\Repositories\DesignationRepository;
|
|
use Modules\Admin\Services\AdminService;
|
|
|
|
class DesignationController extends Controller
|
|
{
|
|
private $designationRepository;
|
|
private $adminService;
|
|
|
|
public function __construct(DesignationRepository $designationRepository, AdminService $adminService)
|
|
{
|
|
$this->designationRepository = $designationRepository;
|
|
$this->adminService = $adminService;
|
|
}
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
$data['title'] = 'Designation List';
|
|
$data['designationLists'] = $this->designationRepository->findAll();
|
|
return view('admin::designations.index', $data);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
$data['title'] = 'Create Designation';
|
|
$data['editable'] = false;
|
|
$data['departmentList'] = $this->adminService->pluckDepartments();
|
|
|
|
return view('admin::designations.create', $data);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$data = $request->except(['_method', '_token']);
|
|
|
|
$this->designationRepository->create($data);
|
|
|
|
flash()->addSuccess('Department Data Created!');
|
|
return redirect()->route('designation.index');
|
|
}
|
|
|
|
/**
|
|
* Show the specified resource.
|
|
*/
|
|
public function show($id)
|
|
{
|
|
return view('admin::designations.show');
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
$data['title'] = 'Edit Designation';
|
|
$data['editable'] = true;
|
|
$data['designation'] = $this->designationRepository->getDesignationById($id);
|
|
$data['departmentList'] = $this->adminService->pluckDepartments();
|
|
|
|
return view('admin::designations.edit', $data);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, $id): RedirectResponse
|
|
{
|
|
$data = $request->except(['_method', '_token']);
|
|
$desgination = $this->designationRepository->getDesignationById($id);
|
|
$desgination->update($data);
|
|
|
|
flash()->addSuccess('Department Data Updated!');
|
|
return redirect()->route('designation.index');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
$this->designationRepository->delete($id);
|
|
flash()->addSuccess('Designation Deleted Succesfully');
|
|
|
|
return response()->json(['status' => true, 'message' => 'Designation Delete Succesfully']);
|
|
}
|
|
}
|