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