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