complete 3.8 with qa test
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Consultation;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class ConsultationReminder24h extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public Consultation $consultation
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$locale = $notifiable->preferred_language ?? 'ar';
|
||||
|
||||
return (new MailMessage)
|
||||
->subject($this->getSubject($locale))
|
||||
->view('emails.reminder-24h', [
|
||||
'consultation' => $this->consultation,
|
||||
'locale' => $locale,
|
||||
'user' => $notifiable,
|
||||
'showPaymentReminder' => $this->shouldShowPaymentReminder(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subject based on locale.
|
||||
*/
|
||||
private function getSubject(string $locale): string
|
||||
{
|
||||
return $locale === 'ar'
|
||||
? 'تذكير: موعدك غداً مع مكتب ليبرا للمحاماة'
|
||||
: 'Reminder: Your consultation is tomorrow';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if payment reminder should be shown.
|
||||
*/
|
||||
private function shouldShowPaymentReminder(): bool
|
||||
{
|
||||
return $this->consultation->consultation_type->value === 'paid' &&
|
||||
$this->consultation->payment_status->value === 'pending';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
'type' => 'consultation_reminder_24h',
|
||||
'consultation_id' => $this->consultation->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Consultation;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class ConsultationReminder2h extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public Consultation $consultation
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$locale = $notifiable->preferred_language ?? 'ar';
|
||||
|
||||
return (new MailMessage)
|
||||
->subject($this->getSubject($locale))
|
||||
->view('emails.reminder-2h', [
|
||||
'consultation' => $this->consultation,
|
||||
'locale' => $locale,
|
||||
'user' => $notifiable,
|
||||
'showPaymentReminder' => $this->shouldShowPaymentReminder(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subject based on locale.
|
||||
*/
|
||||
private function getSubject(string $locale): string
|
||||
{
|
||||
return $locale === 'ar'
|
||||
? 'تذكير: موعدك خلال ساعتين'
|
||||
: 'Reminder: Your consultation is in 2 hours';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if payment reminder should be shown.
|
||||
*/
|
||||
private function shouldShowPaymentReminder(): bool
|
||||
{
|
||||
return $this->consultation->consultation_type->value === 'paid' &&
|
||||
$this->consultation->payment_status->value === 'pending';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
'type' => 'consultation_reminder_2h',
|
||||
'consultation_id' => $this->consultation->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user