From b9a0ba640daece8311ea04a118dd91d77e371c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Tue, 31 Oct 2023 17:40:57 +0300 Subject: [PATCH] added tax events --- app/Events/Setting/TaxCreated.php | 24 ++++++++++++++++++++++++ app/Events/Setting/TaxCreating.php | 20 ++++++++++++++++++++ app/Events/Setting/TaxDeleted.php | 20 ++++++++++++++++++++ app/Events/Setting/TaxDeleting.php | 20 ++++++++++++++++++++ app/Events/Setting/TaxUpdated.php | 24 ++++++++++++++++++++++++ app/Events/Setting/TaxUpdating.php | 24 ++++++++++++++++++++++++ app/Jobs/Setting/CreateTax.php | 6 ++++++ app/Jobs/Setting/DeleteTax.php | 6 ++++++ app/Jobs/Setting/UpdateTax.php | 6 ++++++ 9 files changed, 150 insertions(+) create mode 100644 app/Events/Setting/TaxCreated.php create mode 100644 app/Events/Setting/TaxCreating.php create mode 100644 app/Events/Setting/TaxDeleted.php create mode 100644 app/Events/Setting/TaxDeleting.php create mode 100644 app/Events/Setting/TaxUpdated.php create mode 100644 app/Events/Setting/TaxUpdating.php diff --git a/app/Events/Setting/TaxCreated.php b/app/Events/Setting/TaxCreated.php new file mode 100644 index 00000000000..689127be3f4 --- /dev/null +++ b/app/Events/Setting/TaxCreated.php @@ -0,0 +1,24 @@ +tax = $tax; + $this->request = $request; + } +} diff --git a/app/Events/Setting/TaxCreating.php b/app/Events/Setting/TaxCreating.php new file mode 100644 index 00000000000..b0df2e9a6f2 --- /dev/null +++ b/app/Events/Setting/TaxCreating.php @@ -0,0 +1,20 @@ +request = $request; + } +} diff --git a/app/Events/Setting/TaxDeleted.php b/app/Events/Setting/TaxDeleted.php new file mode 100644 index 00000000000..9feb91a4926 --- /dev/null +++ b/app/Events/Setting/TaxDeleted.php @@ -0,0 +1,20 @@ +tax = $tax; + } +} diff --git a/app/Events/Setting/TaxDeleting.php b/app/Events/Setting/TaxDeleting.php new file mode 100644 index 00000000000..fc69ecdcbc4 --- /dev/null +++ b/app/Events/Setting/TaxDeleting.php @@ -0,0 +1,20 @@ +tax = $tax; + } +} diff --git a/app/Events/Setting/TaxUpdated.php b/app/Events/Setting/TaxUpdated.php new file mode 100644 index 00000000000..5b25699050f --- /dev/null +++ b/app/Events/Setting/TaxUpdated.php @@ -0,0 +1,24 @@ +tax = $tax; + $this->request = $request; + } +} diff --git a/app/Events/Setting/TaxUpdating.php b/app/Events/Setting/TaxUpdating.php new file mode 100644 index 00000000000..cfa037268b4 --- /dev/null +++ b/app/Events/Setting/TaxUpdating.php @@ -0,0 +1,24 @@ +tax = $tax; + $this->request = $request; + } +} diff --git a/app/Jobs/Setting/CreateTax.php b/app/Jobs/Setting/CreateTax.php index af8784a3987..9aa40a8d654 100644 --- a/app/Jobs/Setting/CreateTax.php +++ b/app/Jobs/Setting/CreateTax.php @@ -3,6 +3,8 @@ namespace App\Jobs\Setting; use App\Abstracts\Job; +use App\Events\Setting\TaxCreated; +use App\Events\Setting\TaxCreating; use App\Interfaces\Job\HasOwner; use App\Interfaces\Job\HasSource; use App\Interfaces\Job\ShouldCreate; @@ -12,10 +14,14 @@ class CreateTax extends Job implements HasOwner, HasSource, ShouldCreate { public function handle(): Tax { + event(new TaxCreating($this->request)); + \DB::transaction(function () { $this->model = Tax::create($this->request->all()); }); + event(new TaxCreated($this->model, $this->request)); + return $this->model; } } diff --git a/app/Jobs/Setting/DeleteTax.php b/app/Jobs/Setting/DeleteTax.php index 34fccd728df..8afa5e32c6e 100644 --- a/app/Jobs/Setting/DeleteTax.php +++ b/app/Jobs/Setting/DeleteTax.php @@ -3,6 +3,8 @@ namespace App\Jobs\Setting; use App\Abstracts\Job; +use App\Events\Setting\TaxDeleted; +use App\Events\Setting\TaxDeleting; use App\Interfaces\Job\ShouldDelete; class DeleteTax extends Job implements ShouldDelete @@ -11,10 +13,14 @@ public function handle(): bool { $this->authorize(); + event(new TaxDeleting($this->model)); + \DB::transaction(function () { $this->model->delete(); }); + event(new TaxDeleted($this->model)); + return true; } diff --git a/app/Jobs/Setting/UpdateTax.php b/app/Jobs/Setting/UpdateTax.php index 4f01cf2ef37..5d5584baa3c 100644 --- a/app/Jobs/Setting/UpdateTax.php +++ b/app/Jobs/Setting/UpdateTax.php @@ -3,6 +3,8 @@ namespace App\Jobs\Setting; use App\Abstracts\Job; +use App\Events\Setting\TaxUpdated; +use App\Events\Setting\TaxUpdating; use App\Interfaces\Job\ShouldUpdate; use App\Models\Setting\Tax; @@ -12,10 +14,14 @@ public function handle(): Tax { $this->authorize(); + event(new TaxUpdating($this->model, $this->request)); + \DB::transaction(function () { $this->model->update($this->request->all()); }); + event(new TaxUpdated($this->model, $this->request)); + return $this->model; }