Lae/app/Notifications/CommonNotification.php
2023-01-01 21:01:13 +08:00

69 lines
1.4 KiB
PHP

<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class CommonNotification extends Notification implements ShouldQueue
{
use Queueable;
public string $title;
public string $content;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(string $title, string $content)
{
$this->title = $title;
$this->content = $content;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable): array
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return MailMessage
*/
public function toMail($notifiable): MailMessage
{
return (new MailMessage)->subject($this->title)->markdown('mail.common', [
'title' => $this->title,
'content' => $this->content,
]);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable): array
{
return [
//
];
}
}