56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class SessionMessage extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public $subjectLine;
|
|
public $bodyHtml;
|
|
|
|
public function __construct(string $subject, string $bodyHtml)
|
|
{
|
|
$this->subjectLine = $subject;
|
|
$this->bodyHtml = $bodyHtml;
|
|
}
|
|
|
|
public function build()
|
|
{
|
|
$fromAddress = env('CREST_MAIL_FROM', config('mail.from.address'));
|
|
$fromName = env('CREST_MAIL_FROM_NAME', config('mail.from.name', 'CREST'));
|
|
|
|
$logoUrl = $this->resolveLogoUrl();
|
|
|
|
return $this->view('email.session-message')
|
|
->from($fromAddress, $fromName)
|
|
->replyTo($fromAddress, $fromName)
|
|
->subject($this->subjectLine)
|
|
->with([
|
|
'bodyHtml' => $this->bodyHtml,
|
|
'logoUrl' => $logoUrl,
|
|
]);
|
|
}
|
|
|
|
protected function resolveLogoUrl(): string
|
|
{
|
|
$candidates = [
|
|
public_path('images/crest-logo.jpeg'),
|
|
public_path('assets/images/crest-logo.jpeg'),
|
|
public_path('road/brochure/crest-logo.png'),
|
|
];
|
|
|
|
foreach ($candidates as $path) {
|
|
if (file_exists($path)) {
|
|
return asset(str_replace(public_path(), '', $path));
|
|
}
|
|
}
|
|
|
|
return 'https://road.xltr.in/images/crest-logo.jpeg';
|
|
}
|
|
}
|