diff --git a/app/Events/Banking/TransactionCreated.php b/app/Events/Banking/TransactionCreated.php new file mode 100644 index 000000000..d7da55c57 --- /dev/null +++ b/app/Events/Banking/TransactionCreated.php @@ -0,0 +1,22 @@ +transaction = $transaction; + } +} diff --git a/app/Events/Banking/TransactionCreating.php b/app/Events/Banking/TransactionCreating.php new file mode 100644 index 000000000..1e3252625 --- /dev/null +++ b/app/Events/Banking/TransactionCreating.php @@ -0,0 +1,22 @@ +request = $request; + } +} diff --git a/app/Jobs/Banking/CreateTransaction.php b/app/Jobs/Banking/CreateTransaction.php index 7b03c2f41..6c31ca9ea 100644 --- a/app/Jobs/Banking/CreateTransaction.php +++ b/app/Jobs/Banking/CreateTransaction.php @@ -4,10 +4,14 @@ namespace App\Jobs\Banking; use App\Abstracts\Job; use App\Models\Banking\Transaction; +use App\Events\Banking\TransactionCreated; +use App\Events\Banking\TransactionCreating; class CreateTransaction extends Job { protected $request; + + protected $transaction; /** * Create a new job instance. @@ -26,18 +30,22 @@ class CreateTransaction extends Job */ public function handle() { - $transaction = Transaction::create($this->request->all()); + event(new TransactionCreating($this->request)); + + $this->transaction = Transaction::create($this->request->all()); // Upload attachment if ($this->request->file('attachment')) { $media = $this->getMedia($this->request->file('attachment'), 'transactions'); - $transaction->attachMedia($media, 'attachment'); + $this->transaction->attachMedia($media, 'attachment'); } // Recurring - $transaction->createRecurring(); + $this->transaction->createRecurring(); - return $transaction; + event(new TransactionCreated($this->transaction)); + + return $this->transaction; } }