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