2021-06-26 17:23:15 +02:00
|
|
|
<?php
|
|
|
|
|
2023-09-11 20:26:28 +02:00
|
|
|
namespace BookStack\App;
|
2018-12-16 21:44:57 +01:00
|
|
|
|
2023-09-17 17:20:21 +02:00
|
|
|
use BookStack\Translation\LocaleDefinition;
|
2023-09-02 16:11:42 +02:00
|
|
|
use BookStack\Users\Models\User;
|
2018-12-16 21:44:57 +01:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
2023-09-02 16:11:42 +02:00
|
|
|
abstract class MailNotification extends Notification implements ShouldQueue
|
2018-12-16 21:44:57 +01:00
|
|
|
{
|
|
|
|
use Queueable;
|
|
|
|
|
2023-09-02 16:11:42 +02:00
|
|
|
/**
|
|
|
|
* Get the mail representation of the notification.
|
|
|
|
*/
|
|
|
|
abstract public function toMail(User $notifiable): MailMessage;
|
|
|
|
|
2018-12-16 21:44:57 +01:00
|
|
|
/**
|
|
|
|
* Get the notification's channels.
|
|
|
|
*
|
2021-06-26 17:23:15 +02:00
|
|
|
* @param mixed $notifiable
|
|
|
|
*
|
2018-12-16 21:44:57 +01:00
|
|
|
* @return array|string
|
|
|
|
*/
|
|
|
|
public function via($notifiable)
|
|
|
|
{
|
|
|
|
return ['mail'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new mail message.
|
|
|
|
*/
|
2023-09-17 17:20:21 +02:00
|
|
|
protected function newMailMessage(?LocaleDefinition $locale = null): MailMessage
|
2018-12-16 21:44:57 +01:00
|
|
|
{
|
2023-09-17 17:20:21 +02:00
|
|
|
$data = ['locale' => $locale ?? user()->getLocale()];
|
2023-09-02 16:11:42 +02:00
|
|
|
|
2021-06-26 17:23:15 +02:00
|
|
|
return (new MailMessage())->view([
|
2018-12-16 21:44:57 +01:00
|
|
|
'html' => 'vendor.notifications.email',
|
2021-06-26 17:23:15 +02:00
|
|
|
'text' => 'vendor.notifications.email-plain',
|
2023-09-02 16:11:42 +02:00
|
|
|
], $data);
|
2018-12-16 21:44:57 +01:00
|
|
|
}
|
2019-01-27 11:29:23 +01:00
|
|
|
}
|