]> BookStack Code Mirror - bookstack/blob - app/Activity/Notifications/Messages/BaseActivityNotification.php
a2045c8dcd4e7117fc32dcf4026538276ac63aec
[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\Notifications\MailNotification;
8 use BookStack\Users\Models\User;
9 use Illuminate\Bus\Queueable;
10
11 abstract class BaseActivityNotification extends MailNotification
12 {
13     use Queueable;
14
15     public function __construct(
16         protected Loggable|string $detail,
17         protected User $user,
18     ) {
19     }
20
21     /**
22      * Get the array representation of the notification.
23      *
24      * @param  mixed  $notifiable
25      * @return array
26      */
27     public function toArray($notifiable)
28     {
29         return [
30             'activity_detail' => $this->detail,
31             'activity_creator' => $this->user,
32         ];
33     }
34
35     /**
36      * Build the common reason footer line used in mail messages.
37      */
38     protected function buildReasonFooterLine(string $language): LinkedMailMessageLine
39     {
40         return new LinkedMailMessageLine(
41             url('/preferences/notifications'),
42             trans('notifications.footer_reason', [], $language),
43             trans('notifications.footer_reason_link', [], $language),
44         );
45     }
46 }