model = $department_managment; parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(DepartmentManagmentAdminRequest $request) { if ($request->wantsJson()) { $array = $this->model->json(); foreach ($array as $key => $row) { $array[$key] = array_only($row, config('hrm.department_managment.listfields')); } return ['data' => $array]; } $this->theme->prependTitle(trans('hrm::department_managment.names').' :: '); return $this->theme->of('hrm::admin.department_managment.index')->render(); } /** * Display the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function show(DepartmentManagmentAdminRequest $request, $id) { $department_managment = $this->model->find($id); if (empty($department_managment)) { if ($request->wantsJson()) { return []; } return view('hrm::admin.department_managment.new'); } if ($request->wantsJson()) { return $department_managment; } Former::populate($department_managment); return view('hrm::admin.department_managment.show', compact('department_managment')); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(DepartmentManagmentAdminRequest $request) { $department_managment = $this->model->findOrNew(0); Former::populate($department_managment); return view('hrm::admin.department_managment.create', compact('department_managment')); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(DepartmentManagmentAdminRequest $request) { try { $attributes = $request->all(); $department_managment = $this->model->create($attributes); return $this->success(trans('messages.success.created', ['Module' => trans('hrm::department_managment.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function edit(DepartmentManagmentAdminRequest $request, $id) { $department_managment = $this->model->find($id); Former::populate($department_managment); return view('hrm::admin.department_managment.edit', compact('department_managment')); } /** * Update the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function update(DepartmentManagmentAdminRequest $request, $id) { try { $attributes = $request->all(); $department_managment = $this->model->update($attributes, $id); return $this->success(trans('messages.success.updated', ['Module' => trans('hrm::department_managment.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(DepartmentManagmentAdminRequest $request, $id) { try { $this->model->delete($id); return $this->success(trans('message.success.deleted', ['Module' => trans('hrm::department_managment.name')]), 200); } catch (Exception $e) { return $this->error($e->getMessage()); } } }