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