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