87 lines
2.2 KiB
PHP
87 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\Consultation;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class GuestBookingRejectedMail extends Mailable implements ShouldQueue
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
/**
|
|
* Create a new message instance.
|
|
*/
|
|
public function __construct(
|
|
public Consultation $consultation,
|
|
public string $emailLocale = 'en',
|
|
public ?string $reason = null
|
|
) {}
|
|
|
|
/**
|
|
* Get the message envelope.
|
|
*/
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(
|
|
subject: $this->emailLocale === 'ar'
|
|
? 'تحديث الحجز - مكتب ليبرا للمحاماة'
|
|
: 'Booking Update - Libra Law Firm',
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the message content definition.
|
|
*/
|
|
public function content(): Content
|
|
{
|
|
return new Content(
|
|
markdown: 'emails.booking.guest-rejected.'.$this->emailLocale,
|
|
with: [
|
|
'consultation' => $this->consultation,
|
|
'guestName' => $this->consultation->guest_name,
|
|
'formattedDate' => $this->getFormattedDate(),
|
|
'formattedTime' => $this->getFormattedTime(),
|
|
'reason' => $this->reason,
|
|
'hasReason' => ! empty($this->reason),
|
|
],
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the attachments for the message.
|
|
*
|
|
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
|
*/
|
|
public function attachments(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get formatted date based on locale.
|
|
*/
|
|
private function getFormattedDate(): string
|
|
{
|
|
$date = $this->consultation->booking_date;
|
|
|
|
return $this->emailLocale === 'ar'
|
|
? $date->format('d/m/Y')
|
|
: $date->format('m/d/Y');
|
|
}
|
|
|
|
/**
|
|
* Get formatted time.
|
|
*/
|
|
private function getFormattedTime(): string
|
|
{
|
|
return Carbon::parse($this->consultation->booking_time)->format('h:i A');
|
|
}
|
|
}
|