complete story 8.3 with qa test
This commit is contained in:
@@ -3,13 +3,15 @@
|
||||
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 BookingSubmittedMail extends Mailable
|
||||
class BookingSubmittedMail extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
@@ -18,7 +20,7 @@ class BookingSubmittedMail extends Mailable
|
||||
*/
|
||||
public function __construct(public Consultation $consultation)
|
||||
{
|
||||
$this->locale = $consultation->user->preferred_language ?? 'en';
|
||||
$this->locale = $consultation->user->preferred_language ?? 'ar';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,8 +28,12 @@ class BookingSubmittedMail extends Mailable
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$locale = $this->consultation->user->preferred_language ?? 'ar';
|
||||
|
||||
return new Envelope(
|
||||
subject: __('emails.booking_submitted_subject'),
|
||||
subject: $locale === 'ar'
|
||||
? 'تم استلام طلب الاستشارة'
|
||||
: 'Your Consultation Request Has Been Submitted',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,15 +42,54 @@ class BookingSubmittedMail extends Mailable
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
$locale = $this->consultation->user->preferred_language ?? 'ar';
|
||||
|
||||
return new Content(
|
||||
view: 'emails.booking-submitted',
|
||||
markdown: 'emails.booking.submitted.'.$locale,
|
||||
with: [
|
||||
'consultation' => $this->consultation,
|
||||
'user' => $this->consultation->user,
|
||||
'summaryPreview' => $this->getSummaryPreview(),
|
||||
'formattedDate' => $this->getFormattedDate($locale),
|
||||
'formattedTime' => $this->getFormattedTime(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get truncated summary preview (max 200 characters).
|
||||
*/
|
||||
public function getSummaryPreview(): string
|
||||
{
|
||||
$summary = $this->consultation->problem_summary ?? '';
|
||||
|
||||
return strlen($summary) > 200
|
||||
? substr($summary, 0, 200).'...'
|
||||
: $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get formatted date based on locale.
|
||||
*/
|
||||
public function getFormattedDate(string $locale): string
|
||||
{
|
||||
$date = $this->consultation->booking_date;
|
||||
|
||||
return $locale === 'ar'
|
||||
? $date->format('d/m/Y')
|
||||
: $date->format('m/d/Y');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get formatted time.
|
||||
*/
|
||||
public function getFormattedTime(): string
|
||||
{
|
||||
$time = $this->consultation->booking_time;
|
||||
|
||||
return Carbon::parse($time)->format('h:i A');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user