Merge pull request #3031 from CihanSenturk/add-transaction-delete-events

Added transaction delete events
This commit is contained in:
Cüneyt Şentürk 2023-08-23 11:48:43 +03:00 committed by GitHub
commit a863737315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<?php
namespace App\Events\Banking;
use App\Abstracts\Event;
class TransactionDeleted extends Event
{
public $transaction;
/**
* Create a new event instance.
*
* @param $transaction
*/
public function __construct($transaction)
{
$this->transaction = $transaction;
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Events\Banking;
use App\Abstracts\Event;
class TransactionDeleting extends Event
{
public $transaction;
/**
* Create a new event instance.
*
* @param $transaction
*/
public function __construct($transaction)
{
$this->transaction = $transaction;
}
}

View File

@ -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;
}