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