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