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