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