Added Transaction job new events..
This commit is contained in:
parent
a423be8cdd
commit
cadfff459c
26
app/Events/Banking/DocumentTransactionCreated.php
Normal file
26
app/Events/Banking/DocumentTransactionCreated.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Banking;
|
||||||
|
|
||||||
|
use App\Abstracts\Event;
|
||||||
|
use App\Models\Banking\Transaction;
|
||||||
|
use App\Models\Document\Document;
|
||||||
|
|
||||||
|
class DocumentTransactionCreated extends Event
|
||||||
|
{
|
||||||
|
public $document;
|
||||||
|
|
||||||
|
public $transaction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $document
|
||||||
|
* @param $transaction
|
||||||
|
*/
|
||||||
|
public function __construct(Document $document, Transaction $transaction)
|
||||||
|
{
|
||||||
|
$this->document = $document;
|
||||||
|
$this->transaction = $transaction;
|
||||||
|
}
|
||||||
|
}
|
25
app/Events/Banking/DocumentTransactionCreating.php
Normal file
25
app/Events/Banking/DocumentTransactionCreating.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Banking;
|
||||||
|
|
||||||
|
use App\Abstracts\Event;
|
||||||
|
use App\Models\Document\Document;
|
||||||
|
|
||||||
|
class DocumentTransactionCreating extends Event
|
||||||
|
{
|
||||||
|
public $document;
|
||||||
|
|
||||||
|
public $request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $document
|
||||||
|
* @param $request
|
||||||
|
*/
|
||||||
|
public function __construct(Document $document, $request)
|
||||||
|
{
|
||||||
|
$this->document = $document;
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
}
|
30
app/Events/Banking/DocumentTransactionUpdated.php
Normal file
30
app/Events/Banking/DocumentTransactionUpdated.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Banking;
|
||||||
|
|
||||||
|
use App\Abstracts\Event;
|
||||||
|
use App\Models\Banking\Transaction;
|
||||||
|
use App\Models\Document\Document;
|
||||||
|
|
||||||
|
class DocumentTransactionUpdated extends Event
|
||||||
|
{
|
||||||
|
public $document;
|
||||||
|
|
||||||
|
public $transaction;
|
||||||
|
|
||||||
|
public $request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $document
|
||||||
|
* @param $transaction
|
||||||
|
* @param $request
|
||||||
|
*/
|
||||||
|
public function __construct(Document $document, Transaction $transaction, $request)
|
||||||
|
{
|
||||||
|
$this->document = $document;
|
||||||
|
$this->transaction = $transaction;
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
}
|
30
app/Events/Banking/DocumentTransactionUpdating.php
Normal file
30
app/Events/Banking/DocumentTransactionUpdating.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Banking;
|
||||||
|
|
||||||
|
use App\Abstracts\Event;
|
||||||
|
use App\Models\Banking\Transaction;
|
||||||
|
use App\Models\Document\Document;
|
||||||
|
|
||||||
|
class DocumentTransactionUpdating extends Event
|
||||||
|
{
|
||||||
|
public $document;
|
||||||
|
|
||||||
|
public $transaction;
|
||||||
|
|
||||||
|
public $request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $document
|
||||||
|
* @param $transaction
|
||||||
|
* @param $request
|
||||||
|
*/
|
||||||
|
public function __construct(Document $document, Transaction $transaction, $request)
|
||||||
|
{
|
||||||
|
$this->document = $document;
|
||||||
|
$this->transaction = $transaction;
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
}
|
25
app/Events/Banking/TransactionUpdated.php
Normal file
25
app/Events/Banking/TransactionUpdated.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Banking;
|
||||||
|
|
||||||
|
use App\Abstracts\Event;
|
||||||
|
use App\Models\Banking\Transaction;
|
||||||
|
|
||||||
|
class TransactionUpdated extends Event
|
||||||
|
{
|
||||||
|
public $transaction;
|
||||||
|
|
||||||
|
public $request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $transaction
|
||||||
|
* @param $request
|
||||||
|
*/
|
||||||
|
public function __construct(Transaction $transaction, $request)
|
||||||
|
{
|
||||||
|
$this->transaction = $transaction;
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
}
|
25
app/Events/Banking/TransactionUpdating.php
Normal file
25
app/Events/Banking/TransactionUpdating.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Banking;
|
||||||
|
|
||||||
|
use App\Abstracts\Event;
|
||||||
|
use App\Models\Banking\Transaction;
|
||||||
|
|
||||||
|
class TransactionUpdating extends Event
|
||||||
|
{
|
||||||
|
public $transaction;
|
||||||
|
|
||||||
|
public $request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $transaction
|
||||||
|
* @param $request
|
||||||
|
*/
|
||||||
|
public function __construct(Transaction $transaction, $request)
|
||||||
|
{
|
||||||
|
$this->transaction = $transaction;
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@
|
|||||||
namespace App\Jobs\Banking;
|
namespace App\Jobs\Banking;
|
||||||
|
|
||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
|
use App\Events\Banking\DocumentTransactionCreated;
|
||||||
|
use App\Events\Banking\DocumentTransactionCreating;
|
||||||
use App\Jobs\Banking\CreateTransaction;
|
use App\Jobs\Banking\CreateTransaction;
|
||||||
use App\Jobs\Document\CreateDocumentHistory;
|
use App\Jobs\Document\CreateDocumentHistory;
|
||||||
use App\Events\Document\PaidAmountCalculated;
|
use App\Events\Document\PaidAmountCalculated;
|
||||||
@ -27,6 +29,8 @@ class CreateBankingDocumentTransaction extends Job implements ShouldCreate
|
|||||||
|
|
||||||
public function handle(): Transaction
|
public function handle(): Transaction
|
||||||
{
|
{
|
||||||
|
event(new DocumentTransactionCreating($this->model, $this->request));
|
||||||
|
|
||||||
$this->prepareRequest();
|
$this->prepareRequest();
|
||||||
|
|
||||||
$this->checkAmount();
|
$this->checkAmount();
|
||||||
@ -46,6 +50,8 @@ class CreateBankingDocumentTransaction extends Job implements ShouldCreate
|
|||||||
$this->createHistory();
|
$this->createHistory();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
event(new DocumentTransactionCreated($this->model, $this->transaction));
|
||||||
|
|
||||||
return $this->transaction;
|
return $this->transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
namespace App\Jobs\Banking;
|
namespace App\Jobs\Banking;
|
||||||
|
|
||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
|
use App\Events\Banking\DocumentTransactionUpdated;
|
||||||
|
use App\Events\Banking\DocumentTransactionUpdating;
|
||||||
|
use App\Events\Document\PaidAmountCalculated;
|
||||||
use App\Jobs\Banking\UpdateTransaction;
|
use App\Jobs\Banking\UpdateTransaction;
|
||||||
use App\Jobs\Document\CreateDocumentHistory;
|
use App\Jobs\Document\CreateDocumentHistory;
|
||||||
use App\Events\Document\PaidAmountCalculated;
|
|
||||||
use App\Interfaces\Job\ShouldUpdate;
|
use App\Interfaces\Job\ShouldUpdate;
|
||||||
use App\Models\Banking\Transaction;
|
use App\Models\Banking\Transaction;
|
||||||
use App\Models\Document\Document;
|
use App\Models\Document\Document;
|
||||||
@ -26,6 +28,8 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate
|
|||||||
|
|
||||||
public function handle(): Transaction
|
public function handle(): Transaction
|
||||||
{
|
{
|
||||||
|
event(new DocumentTransactionUpdating($this->model, $this->transaction, $this->request));
|
||||||
|
|
||||||
$this->prepareRequest();
|
$this->prepareRequest();
|
||||||
|
|
||||||
$this->checkAmount();
|
$this->checkAmount();
|
||||||
@ -45,6 +49,8 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate
|
|||||||
$this->createHistory();
|
$this->createHistory();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
event(new DocumentTransactionUpdated($this->model, $this->transaction, $this->request));
|
||||||
|
|
||||||
return $this->transaction;
|
return $this->transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
namespace App\Jobs\Banking;
|
namespace App\Jobs\Banking;
|
||||||
|
|
||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
|
use App\Events\Banking\TransactionUpdated;
|
||||||
|
use App\Events\Banking\TransactionUpdating;
|
||||||
use App\Interfaces\Job\ShouldUpdate;
|
use App\Interfaces\Job\ShouldUpdate;
|
||||||
use App\Models\Banking\Transaction;
|
use App\Models\Banking\Transaction;
|
||||||
|
|
||||||
@ -12,6 +14,8 @@ class UpdateTransaction extends Job implements ShouldUpdate
|
|||||||
{
|
{
|
||||||
$this->authorize();
|
$this->authorize();
|
||||||
|
|
||||||
|
event(new TransactionUpdating($this->model, $this->request));
|
||||||
|
|
||||||
\DB::transaction(function () {
|
\DB::transaction(function () {
|
||||||
$this->model->update($this->request->all());
|
$this->model->update($this->request->all());
|
||||||
|
|
||||||
@ -32,6 +36,8 @@ class UpdateTransaction extends Job implements ShouldUpdate
|
|||||||
$this->model->updateRecurring($this->request->all());
|
$this->model->updateRecurring($this->request->all());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
event(new TransactionUpdated($this->model, $this->request));
|
||||||
|
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user