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