]> BookStack Code Mirror - bookstack/blob - app/App/MailNotification.php
Update UserPreferencesTest.php
[bookstack] / app / App / MailNotification.php
1 <?php
2
3 namespace BookStack\App;
4
5 use BookStack\Users\Models\User;
6 use Illuminate\Bus\Queueable;
7 use Illuminate\Contracts\Queue\ShouldQueue;
8 use Illuminate\Notifications\Messages\MailMessage;
9 use Illuminate\Notifications\Notification;
10
11 abstract class MailNotification extends Notification implements ShouldQueue
12 {
13     use Queueable;
14
15     /**
16      * Get the mail representation of the notification.
17      */
18     abstract public function toMail(User $notifiable): MailMessage;
19
20     /**
21      * Get the notification's channels.
22      *
23      * @param mixed $notifiable
24      *
25      * @return array|string
26      */
27     public function via($notifiable)
28     {
29         return ['mail'];
30     }
31
32     /**
33      * Create a new mail message.
34      */
35     protected function newMailMessage(string $language = ''): MailMessage
36     {
37         $data = ['language' => $language ?: null];
38
39         return (new MailMessage())->view([
40             'html' => 'vendor.notifications.email',
41             'text' => 'vendor.notifications.email-plain',
42         ], $data);
43     }
44 }