repository = $resignation; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Hrm\Resignation\Repositories\Criteria\ResignationResourceCriteria::class); } /** * Display a list of resignation. * * @return Response */ public function index(ResignationRequest $request) { return $this->repository ->setPresenter(\Hrm\Resignation\Repositories\Presenter\ResignationPresenter::class) ->paginate(); } /** * Display resignation. * * @param Request $request * @param Model $resignation * * @return Response */ public function show(ResignationRequest $request, Resignation $resignation) { return $resignation->setPresenter(\Hrm\Resignation\Repositories\Presenter\ResignationListPresenter::class); ; } /** * Create new resignation. * * @param Request $request * * @return Response */ public function store(ResignationRequest $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('resignation::resignation.name')]); $code = 204; $status = 'success'; $url = guard_url('resignation/resignation/' . $resignation->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('resignation/resignation'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the resignation. * * @param Request $request * @param Model $resignation * * @return Response */ public function update(ResignationRequest $request, Resignation $resignation) { try { $data = $request->all(); $resignation->update($data); $message = trans('messages.success.updated', ['Module' => trans('resignation::resignation.name')]); $code = 204; $status = 'success'; $url = guard_url('resignation/resignation/' . $resignation->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('resignation/resignation/' . $resignation->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the resignation. * * @param Model $resignation * * @return Response */ public function destroy(ResignationRequest $request, Resignation $resignation) { try { $resignation->delete(); $message = trans('messages.success.deleted', ['Module' => trans('resignation::resignation.name')]); $code = 202; $status = 'success'; $url = guard_url('resignation/resignation/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('resignation/resignation/' . $resignation->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); } }