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