libra/app/Notifications/BookingRejected.php

56 lines
1.3 KiB
PHP

<?php
namespace App\Notifications;
use App\Mail\BookingRejectedEmail;
use App\Models\Consultation;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Notifications\Notification;
class BookingRejected extends Notification implements ShouldQueue
{
use Queueable;
/**
* Create a new notification instance.
*/
public function __construct(
public Consultation $consultation,
public ?string $rejectionReason = null
) {}
/**
* 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): Mailable
{
return (new BookingRejectedEmail($this->consultation, $this->rejectionReason))
->to($notifiable->email);
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'type' => 'booking_rejected',
'consultation_id' => $this->consultation->id,
];
}
}