]> BookStack Code Mirror - bookstack/blob - app/Activity/Notifications/Messages/BaseActivityNotification.php
Fixed OIDC Logout
[bookstack] / app / Activity / Notifications / Messages / BaseActivityNotification.php
1 <?php
2
3 namespace BookStack\Activity\Notifications\Messages;
4
5 use BookStack\Activity\Models\Loggable;
6 use BookStack\Activity\Notifications\MessageParts\LinkedMailMessageLine;
7 use BookStack\Users\Models\User;
8 use Illuminate\Bus\Queueable;
9 use Illuminate\Notifications\Messages\MailMessage;
10 use Illuminate\Notifications\Notification;
11
12 abstract class BaseActivityNotification extends Notification
13 {
14     use Queueable;
15
16     public function __construct(
17         protected Loggable|string $detail,
18         protected User $user,
19     ) {
20     }
21
22     /**
23      * Get the notification's delivery channels.
24      *
25      * @param  mixed  $notifiable
26      * @return array
27      */
28     public function via($notifiable)
29     {
30         return ['mail'];
31     }
32
33     /**
34      * Get the mail representation of the notification.
35      */
36     abstract public function toMail(mixed $notifiable): MailMessage;
37
38     /**
39      * Get the array representation of the notification.
40      *
41      * @param  mixed  $notifiable
42      * @return array
43      */
44     public function toArray($notifiable)
45     {
46         return [
47             'activity_detail' => $this->detail,
48             'activity_creator' => $this->user,
49         ];
50     }
51
52     /**
53      * Build the common reason footer line used in mail messages.
54      */
55     protected function buildReasonFooterLine(): LinkedMailMessageLine
56     {
57         return new LinkedMailMessageLine(
58             url('/preferences/notifications'),
59             trans('notifications.footer_reason'),
60             trans('notifications.footer_reason_link'),
61         );
62     }
63 }