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