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) { return $this->repository ->setPresenter(\Bixo\Deal\Repositories\Presenter\ConveyancingPresenter::class) ->paginate(); } /** * Display conveyancing. * * @param Request $request * @param Model $conveyancing * * @return Response */ public function show(ConveyancingRequest $request, Conveyancing $conveyancing) { return $conveyancing->setPresenter(\Bixo\Deal\Repositories\Presenter\ConveyancingListPresenter::class); ; } /** * Create new conveyancing. * * @param Request $request * * @return Response */ public function store(ConveyancingRequest $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('deal::conveyancing.name')]); $code = 204; $status = 'success'; $url = guard_url('deal/conveyancing/' . $conveyancing->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('deal/conveyancing'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the conveyancing. * * @param Request $request * @param Model $conveyancing * * @return Response */ public function update(ConveyancingRequest $request, Conveyancing $conveyancing) { try { $data = $request->all(); $conveyancing->update($data); $message = trans('messages.success.updated', ['Module' => trans('deal::conveyancing.name')]); $code = 204; $status = 'success'; $url = guard_url('deal/conveyancing/' . $conveyancing->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('deal/conveyancing/' . $conveyancing->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the conveyancing. * * @param Model $conveyancing * * @return Response */ public function destroy(ConveyancingRequest $request, Conveyancing $conveyancing) { try { $conveyancing->delete(); $message = trans('messages.success.deleted', ['Module' => trans('deal::conveyancing.name')]); $code = 202; $status = 'success'; $url = guard_url('deal/conveyancing/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('deal/conveyancing/' . $conveyancing->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); } }