dispatch(new CreateTax($request)); return $this->created(route('api.taxes.show', $tax->id), new Resource($tax)); } /** * Update the specified resource in storage. * * @param $tax * @param $request * @return \Illuminate\Http\JsonResponse */ public function update(Tax $tax, Request $request) { try { $tax = $this->dispatch(new UpdateTax($tax, $request)); return new Resource($tax->fresh()); } catch(\Exception $e) { $this->errorUnauthorized($e->getMessage()); } } /** * Enable the specified resource in storage. * * @param Tax $tax * @return \Illuminate\Http\JsonResponse */ public function enable(Tax $tax) { $tax = $this->dispatch(new UpdateTax($tax, request()->merge(['enabled' => 1]))); return new Resource($tax->fresh()); } /** * Disable the specified resource in storage. * * @param Tax $tax * @return \Illuminate\Http\JsonResponse */ public function disable(Tax $tax) { try { $tax = $this->dispatch(new UpdateTax($tax, request()->merge(['enabled' => 0]))); return new Resource($tax->fresh()); } catch(\Exception $e) { $this->errorUnauthorized($e->getMessage()); } } /** * Remove the specified resource from storage. * * @param Tax $tax * @return \Illuminate\Http\Response */ public function destroy(Tax $tax) { try { $this->dispatch(new DeleteTax($tax)); return $this->noContent(); } catch(\Exception $e) { $this->errorUnauthorized($e->getMessage()); } } }