From b48bc2bb96b771855b253227c1fed361f0e396ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Sun, 7 Jan 2024 14:47:23 +0100 Subject: [PATCH] add transaction completed event --- src/Events/TransactionCompleted.php | 24 ++++++++++++++++++++++++ src/Models/Transaction.php | 3 +++ 2 files changed, 27 insertions(+) create mode 100644 src/Events/TransactionCompleted.php diff --git a/src/Events/TransactionCompleted.php b/src/Events/TransactionCompleted.php new file mode 100644 index 00000000..3149a382 --- /dev/null +++ b/src/Events/TransactionCompleted.php @@ -0,0 +1,24 @@ +transaction = $transaction; + } +} diff --git a/src/Models/Transaction.php b/src/Models/Transaction.php index 4c8799ca..82b955e0 100644 --- a/src/Models/Transaction.php +++ b/src/Models/Transaction.php @@ -3,6 +3,7 @@ namespace Cone\Bazar\Models; use Cone\Bazar\Database\Factories\TransactionFactory; +use Cone\Bazar\Events\TransactionCompleted; use Cone\Bazar\Interfaces\Models\Transaction as Contract; use Cone\Bazar\Support\Facades\Gateway; use Cone\Root\Traits\InteractsWithProxy; @@ -153,6 +154,8 @@ public function markAsCompleted(?DateTimeInterface $date = null): void if ($this->pending() || $this->completed_at->notEqualTo($date)) { $this->setAttribute('completed_at', $date)->save(); + + TransactionCompleted::dispatch($this); } }