update
This commit is contained in:
@@ -2,65 +2,35 @@
|
||||
|
||||
namespace App\Mail\Customer;
|
||||
|
||||
use App\Mail\Concerns\RequiresDbTemplate;
|
||||
use App\Models\Setting;
|
||||
use App\Mail\TemplateMailable;
|
||||
use App\Support\MailGlobals;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class VerifyAccount extends Mailable
|
||||
class VerifyAccount extends TemplateMailable
|
||||
{
|
||||
use Queueable, SerializesModels, RequiresDbTemplate;
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public function __construct(public array $data) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: $this->renderFromTemplate('verify_account_welcome', $this->vars())['subject'],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
htmlString: $this->renderFromTemplate('verify_account_welcome', $this->vars())['html'],
|
||||
);
|
||||
}
|
||||
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function payload(): array
|
||||
protected function scenario(): string
|
||||
{
|
||||
try {
|
||||
$setting = Setting::where('key', 'setting')->first();
|
||||
$settingValue = $setting ? json_decode((string) $setting->value, true) : [];
|
||||
} catch (\Throwable) {
|
||||
$settingValue = [];
|
||||
}
|
||||
|
||||
return array_merge([
|
||||
'company_name' => $settingValue['company'] ?? config('app.name', 'The Gioi So'),
|
||||
'support_email' => $settingValue['email'] ?? config('mail.support_email', 'support@thegioiso.com'),
|
||||
'support_phone' => $settingValue['hotline'] ?? ($settingValue['phone'] ?? config('mail.support_phone', '1900.xxxx')),
|
||||
], $this->data);
|
||||
return 'verify_account_welcome';
|
||||
}
|
||||
|
||||
private function vars(): array
|
||||
protected function variables(): array
|
||||
{
|
||||
$data = $this->payload();
|
||||
$data = [...MailGlobals::values(), ...$this->data];
|
||||
|
||||
return [
|
||||
'app_name' => $data['company_name'] ?? config('app.name', 'The Gioi So'),
|
||||
'full_name' => $data['fullname'] ?? 'Quý khách',
|
||||
'verify_code' => $data['verify_code'] ?? '',
|
||||
'support_email' => $data['support_email'] ?? config('mail.support_email', 'support@thegioiso.com'),
|
||||
'support_phone' => $data['support_phone'] ?? config('mail.support_phone', '1900.xxxx'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user