Merge pull request #1347 from SevanNerse/dev-jobs
CreateTransaction job is improved
This commit is contained in:
commit
dbee33dd18
22
app/Events/Banking/TransactionCreated.php
Normal file
22
app/Events/Banking/TransactionCreated.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Banking;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class TransactionCreated
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $transaction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $transaction
|
||||||
|
*/
|
||||||
|
public function __construct($transaction)
|
||||||
|
{
|
||||||
|
$this->transaction = $transaction;
|
||||||
|
}
|
||||||
|
}
|
22
app/Events/Banking/TransactionCreating.php
Normal file
22
app/Events/Banking/TransactionCreating.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Banking;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class TransactionCreating
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $request
|
||||||
|
*/
|
||||||
|
public function __construct($request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
}
|
@ -4,10 +4,14 @@ namespace App\Jobs\Banking;
|
|||||||
|
|
||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
use App\Models\Banking\Transaction;
|
use App\Models\Banking\Transaction;
|
||||||
|
use App\Events\Banking\TransactionCreated;
|
||||||
|
use App\Events\Banking\TransactionCreating;
|
||||||
|
|
||||||
class CreateTransaction extends Job
|
class CreateTransaction extends Job
|
||||||
{
|
{
|
||||||
protected $request;
|
protected $request;
|
||||||
|
|
||||||
|
protected $transaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
@ -26,18 +30,22 @@ class CreateTransaction extends Job
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$transaction = Transaction::create($this->request->all());
|
event(new TransactionCreating($this->request));
|
||||||
|
|
||||||
|
$this->transaction = Transaction::create($this->request->all());
|
||||||
|
|
||||||
// Upload attachment
|
// Upload attachment
|
||||||
if ($this->request->file('attachment')) {
|
if ($this->request->file('attachment')) {
|
||||||
$media = $this->getMedia($this->request->file('attachment'), 'transactions');
|
$media = $this->getMedia($this->request->file('attachment'), 'transactions');
|
||||||
|
|
||||||
$transaction->attachMedia($media, 'attachment');
|
$this->transaction->attachMedia($media, 'attachment');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recurring
|
// Recurring
|
||||||
$transaction->createRecurring();
|
$this->transaction->createRecurring();
|
||||||
|
|
||||||
return $transaction;
|
event(new TransactionCreated($this->transaction));
|
||||||
|
|
||||||
|
return $this->transaction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user