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