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