diff --git a/app/Events/Setting/CurrencyCreated.php b/app/Events/Setting/CurrencyCreated.php new file mode 100644 index 000000000..ef286e3d1 --- /dev/null +++ b/app/Events/Setting/CurrencyCreated.php @@ -0,0 +1,24 @@ +currency = $currency; + $this->request = $request; + } +} diff --git a/app/Events/Setting/CurrencyCreating.php b/app/Events/Setting/CurrencyCreating.php new file mode 100644 index 000000000..554d47e3d --- /dev/null +++ b/app/Events/Setting/CurrencyCreating.php @@ -0,0 +1,20 @@ +request = $request; + } +} diff --git a/app/Events/Setting/CurrencyDeleted.php b/app/Events/Setting/CurrencyDeleted.php new file mode 100644 index 000000000..5e7290b54 --- /dev/null +++ b/app/Events/Setting/CurrencyDeleted.php @@ -0,0 +1,20 @@ +currency = $currency; + } +} diff --git a/app/Events/Setting/CurrencyDeleting.php b/app/Events/Setting/CurrencyDeleting.php new file mode 100644 index 000000000..7804091fa --- /dev/null +++ b/app/Events/Setting/CurrencyDeleting.php @@ -0,0 +1,20 @@ +currency = $currency; + } +} diff --git a/app/Events/Setting/CurrencyUpdated.php b/app/Events/Setting/CurrencyUpdated.php new file mode 100644 index 000000000..0fe02edca --- /dev/null +++ b/app/Events/Setting/CurrencyUpdated.php @@ -0,0 +1,24 @@ +currency = $currency; + $this->request = $request; + } +} diff --git a/app/Events/Setting/CurrencyUpdating.php b/app/Events/Setting/CurrencyUpdating.php new file mode 100644 index 000000000..48db083db --- /dev/null +++ b/app/Events/Setting/CurrencyUpdating.php @@ -0,0 +1,24 @@ +currency = $currency; + $this->request = $request; + } +} diff --git a/app/Jobs/Setting/CreateCurrency.php b/app/Jobs/Setting/CreateCurrency.php index 9015e85c9..7730eee97 100644 --- a/app/Jobs/Setting/CreateCurrency.php +++ b/app/Jobs/Setting/CreateCurrency.php @@ -3,6 +3,8 @@ namespace App\Jobs\Setting; use App\Abstracts\Job; +use App\Events\Setting\CurrencyCreated; +use App\Events\Setting\CurrencyCreating; use App\Interfaces\Job\HasOwner; use App\Interfaces\Job\HasSource; use App\Interfaces\Job\ShouldCreate; @@ -12,6 +14,8 @@ class CreateCurrency extends Job implements HasOwner, HasSource, ShouldCreate { public function handle(): Currency { + event(new CurrencyCreating($this->request)); + // Force the rate to be 1 for default currency if ($this->request->get('default_currency')) { $this->request['rate'] = '1'; @@ -27,6 +31,8 @@ class CreateCurrency extends Job implements HasOwner, HasSource, ShouldCreate } }); + event(new CurrencyCreated($this->model, $this->request)); + return $this->model; } } diff --git a/app/Jobs/Setting/DeleteCurrency.php b/app/Jobs/Setting/DeleteCurrency.php index 6f7410561..faa48b0f2 100644 --- a/app/Jobs/Setting/DeleteCurrency.php +++ b/app/Jobs/Setting/DeleteCurrency.php @@ -3,6 +3,8 @@ namespace App\Jobs\Setting; use App\Abstracts\Job; +use App\Events\Setting\CurrencyDeleted; +use App\Events\Setting\CurrencyDeleting; use App\Interfaces\Job\ShouldDelete; class DeleteCurrency extends Job implements ShouldDelete @@ -11,10 +13,14 @@ class DeleteCurrency extends Job implements ShouldDelete { $this->authorize(); + event(new CurrencyDeleting($this->model)); + \DB::transaction(function () { $this->model->delete(); }); + event(new CurrencyDeleted($this->model)); + return true; } diff --git a/app/Jobs/Setting/UpdateCurrency.php b/app/Jobs/Setting/UpdateCurrency.php index 29ce18d6c..1c047b3a3 100644 --- a/app/Jobs/Setting/UpdateCurrency.php +++ b/app/Jobs/Setting/UpdateCurrency.php @@ -3,6 +3,8 @@ namespace App\Jobs\Setting; use App\Abstracts\Job; +use App\Events\Setting\CurrencyUpdated; +use App\Events\Setting\CurrencyUpdating; use App\Interfaces\Job\ShouldUpdate; use App\Models\Setting\Currency; @@ -12,6 +14,8 @@ class UpdateCurrency extends Job implements ShouldUpdate { $this->authorize(); + event(new CurrencyUpdating($this->model, $this->request)); + // Force the rate to be 1 for default currency if ($this->request->get('default_currency')) { $this->request['rate'] = '1'; @@ -27,6 +31,8 @@ class UpdateCurrency extends Job implements ShouldUpdate } }); + event(new CurrencyUpdated($this->model, $this->request)); + return $this->model; }