repository = $tax; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Survey\Employee\Repositories\Criteria\TaxResourceCriteria::class); } /** * Display a list of tax. * * @return Response */ public function index(TaxRequest $request) { return $this->repository ->setPresenter(\Survey\Employee\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(\Survey\Employee\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('employee::tax.name')]); $code = 204; $status = 'success'; $url = guard_url('employee/tax/' . $tax->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('employee/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('employee::tax.name')]); $code = 204; $status = 'success'; $url = guard_url('employee/tax/' . $tax->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('employee/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('employee::tax.name')]); $code = 202; $status = 'success'; $url = guard_url('employee/tax/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('employee/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); } }