repository = $conveyancing; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Bixo\Deal\Repositories\Criteria\ConveyancingResourceCriteria::class); } /** * Display a list of conveyancing. * * @return Response */ public function index(ConveyancingRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Bixo\Deal\Repositories\Presenter\ConveyancingPresenter::class) ->$function(); } $conveyancings = $this->repository->paginate(); return $this->response->setMetaTitle(trans('deal::conveyancing.names')) ->view('deal::conveyancing.index', true) ->data(compact('conveyancings', 'view')) ->output(); } /** * Display conveyancing. * * @param Request $request * @param Model $conveyancing * * @return Response */ public function show(ConveyancingRequest $request, Conveyancing $conveyancing) { if ($conveyancing->exists) { $view = 'deal::conveyancing.show'; } else { $view = 'deal::conveyancing.new'; } return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('deal::conveyancing.name')) ->data(compact('conveyancing')) ->view($view, true) ->output(); } /** * Show the form for creating a new conveyancing. * * @param Request $request * * @return Response */ public function create(ConveyancingRequest $request) { $conveyancing = $this->repository->newInstance([]); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('deal::conveyancing.name')) ->view('deal::conveyancing.create', true) ->data(compact('conveyancing')) ->output(); } /** * Create new conveyancing. * * @param Request $request * * @return Response */ public function store(ConveyancingRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $conveyancing = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('deal::conveyancing.name')])) ->code(204) ->status('success') ->url(guard_url('deal/conveyancing/' . $conveyancing->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/deal/conveyancing')) ->redirect(); } } /** * Show conveyancing for editing. * * @param Request $request * @param Model $conveyancing * * @return Response */ public function edit(ConveyancingRequest $request, Conveyancing $conveyancing) { return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('deal::conveyancing.name')) ->view('deal::conveyancing.edit', true) ->data(compact('conveyancing')) ->output(); } /** * Update the conveyancing. * * @param Request $request * @param Model $conveyancing * * @return Response */ public function update(ConveyancingRequest $request, Conveyancing $conveyancing) { try { $attributes = $request->all(); $conveyancing->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('deal::conveyancing.name')])) ->code(204) ->status('success') ->url(guard_url('deal/conveyancing/' . $conveyancing->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('deal/conveyancing/' . $conveyancing->getRouteKey())) ->redirect(); } } /** * Remove the conveyancing. * * @param Model $conveyancing * * @return Response */ public function destroy(ConveyancingRequest $request, Conveyancing $conveyancing) { try { $conveyancing->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('deal::conveyancing.name')])) ->code(202) ->status('success') ->url(guard_url('deal/conveyancing/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('deal/conveyancing/' . $conveyancing->getRouteKey())) ->redirect(); } } /** * Remove multiple conveyancing. * * @param Model $conveyancing * * @return Response */ public function delete(ConveyancingRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('deal::conveyancing.name')])) ->status("success") ->code(202) ->url(guard_url('deal/conveyancing')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/deal/conveyancing')) ->redirect(); } } /** * Restore deleted conveyancings. * * @param Model $conveyancing * * @return Response */ public function restore(ConveyancingRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('deal::conveyancing.name')])) ->status("success") ->code(202) ->url(guard_url('/deal/conveyancing')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/deal/conveyancing/')) ->redirect(); } } }