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