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