From ec5bff51c1b782df55ba78e228a0d1bc7d579dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Wed, 23 Aug 2023 11:43:17 +0300 Subject: [PATCH] added transaction delete events --- app/Events/Banking/TransactionDeleted.php | 20 ++++++++++++++++++++ app/Events/Banking/TransactionDeleting.php | 20 ++++++++++++++++++++ app/Jobs/Banking/DeleteTransaction.php | 6 ++++++ 3 files changed, 46 insertions(+) create mode 100644 app/Events/Banking/TransactionDeleted.php create mode 100644 app/Events/Banking/TransactionDeleting.php diff --git a/app/Events/Banking/TransactionDeleted.php b/app/Events/Banking/TransactionDeleted.php new file mode 100644 index 000000000..e11ea9976 --- /dev/null +++ b/app/Events/Banking/TransactionDeleted.php @@ -0,0 +1,20 @@ +transaction = $transaction; + } +} diff --git a/app/Events/Banking/TransactionDeleting.php b/app/Events/Banking/TransactionDeleting.php new file mode 100644 index 000000000..f5a0d7b0d --- /dev/null +++ b/app/Events/Banking/TransactionDeleting.php @@ -0,0 +1,20 @@ +transaction = $transaction; + } +} diff --git a/app/Jobs/Banking/DeleteTransaction.php b/app/Jobs/Banking/DeleteTransaction.php index 7561d0a3d..8edac1325 100644 --- a/app/Jobs/Banking/DeleteTransaction.php +++ b/app/Jobs/Banking/DeleteTransaction.php @@ -3,6 +3,8 @@ namespace App\Jobs\Banking; use App\Abstracts\Job; +use App\Events\Banking\TransactionDeleting; +use App\Events\Banking\TransactionDeleted; use App\Interfaces\Job\ShouldDelete; class DeleteTransaction extends Job implements ShouldDelete @@ -11,11 +13,15 @@ class DeleteTransaction extends Job implements ShouldDelete { $this->authorize(); + event(new TransactionDeleting($this->model)); + \DB::transaction(function () { $this->model->recurring()->delete(); $this->model->delete(); }); + event(new TransactionDeleted($this->model)); + return true; }