Merge pull request #3031 from CihanSenturk/add-transaction-delete-events
Added transaction delete events
This commit is contained in:
commit
a863737315
20
app/Events/Banking/TransactionDeleted.php
Normal file
20
app/Events/Banking/TransactionDeleted.php
Normal 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;
|
||||
}
|
||||
}
|
20
app/Events/Banking/TransactionDeleting.php
Normal file
20
app/Events/Banking/TransactionDeleting.php
Normal 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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user