51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Mail\ReversalIssued;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
class SendReversalIssuedMail implements ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
protected $profile;
|
|
protected $bank;
|
|
protected $amount;
|
|
protected $originalTransactionId;
|
|
protected $description;
|
|
|
|
public function __construct($profile, $bank, int $amount, int $originalTransactionId, string $description)
|
|
{
|
|
$this->profile = $profile;
|
|
$this->bank = $bank;
|
|
$this->amount = $amount;
|
|
$this->originalTransactionId = $originalTransactionId;
|
|
$this->description = $description;
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
if (!$this->profile->email) {
|
|
Log::warning('SendReversalIssuedMail: Profile has no email address', [
|
|
'profile_id' => $this->profile->id,
|
|
'profile_type' => get_class($this->profile),
|
|
]);
|
|
return;
|
|
}
|
|
|
|
Mail::to($this->profile->email)->send(
|
|
new ReversalIssued($this->profile, $this->bank, $this->amount, $this->originalTransactionId, $this->description)
|
|
);
|
|
}
|
|
}
|