repository = $disciplinary_category; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Hrm\Disciplinary\Repositories\Criteria\DisciplinaryCategoryResourceCriteria::class); } /** * Display a list of disciplinary_category. * * @return Response */ public function index(DisciplinaryCategoryRequest $request) { return $this->repository ->setPresenter(\Hrm\Disciplinary\Repositories\Presenter\DisciplinaryCategoryPresenter::class) ->paginate(); } /** * Display disciplinary_category. * * @param Request $request * @param Model $disciplinary_category * * @return Response */ public function show(DisciplinaryCategoryRequest $request, DisciplinaryCategory $disciplinary_category) { return $disciplinary_category->setPresenter(\Hrm\Disciplinary\Repositories\Presenter\DisciplinaryCategoryListPresenter::class); ; } /** * Create new disciplinary_category. * * @param Request $request * * @return Response */ public function store(DisciplinaryCategoryRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('disciplinary::disciplinary_category.name')]); $code = 204; $status = 'success'; $url = guard_url('disciplinary/disciplinary_category/' . $disciplinary_category->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('disciplinary/disciplinary_category'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the disciplinary_category. * * @param Request $request * @param Model $disciplinary_category * * @return Response */ public function update(DisciplinaryCategoryRequest $request, DisciplinaryCategory $disciplinary_category) { try { $data = $request->all(); $disciplinary_category->update($data); $message = trans('messages.success.updated', ['Module' => trans('disciplinary::disciplinary_category.name')]); $code = 204; $status = 'success'; $url = guard_url('disciplinary/disciplinary_category/' . $disciplinary_category->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('disciplinary/disciplinary_category/' . $disciplinary_category->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the disciplinary_category. * * @param Model $disciplinary_category * * @return Response */ public function destroy(DisciplinaryCategoryRequest $request, DisciplinaryCategory $disciplinary_category) { try { $disciplinary_category->delete(); $message = trans('messages.success.deleted', ['Module' => trans('disciplinary::disciplinary_category.name')]); $code = 202; $status = 'success'; $url = guard_url('disciplinary/disciplinary_category/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('disciplinary/disciplinary_category/' . $disciplinary_category->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }