2023-08-04 19:27:29 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Activity\Notifications\Messages;
|
|
|
|
|
2023-08-15 21:39:39 +08:00
|
|
|
use BookStack\Activity\Notifications\MessageParts\ListMessageLine;
|
2023-08-04 19:27:29 +08:00
|
|
|
use BookStack\Entities\Models\Page;
|
2023-10-26 20:01:38 +08:00
|
|
|
use BookStack\Entities\Models\Chapter;
|
2023-09-02 22:11:42 +08:00
|
|
|
use BookStack\Users\Models\User;
|
2023-08-04 19:27:29 +08:00
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
|
|
|
|
class PageCreationNotification extends BaseActivityNotification
|
|
|
|
{
|
2023-09-02 22:11:42 +08:00
|
|
|
public function toMail(User $notifiable): MailMessage
|
2023-08-04 19:27:29 +08:00
|
|
|
{
|
|
|
|
/** @var Page $page */
|
|
|
|
$page = $this->detail;
|
2023-10-26 20:01:38 +08:00
|
|
|
$book = $page->book;
|
|
|
|
$chapterId = $page->chapter_id;
|
|
|
|
$chapter = $chapterId ? Chapter::find($chapterId) : null;
|
2023-08-04 19:27:29 +08:00
|
|
|
|
2023-09-17 23:20:21 +08:00
|
|
|
$locale = $notifiable->getLocale();
|
2023-09-02 22:11:42 +08:00
|
|
|
|
2023-10-26 20:01:38 +08:00
|
|
|
$listMessageData = [
|
|
|
|
$locale->trans('notifications.detail_page_name') => $page->name,
|
|
|
|
'' => '',
|
|
|
|
];
|
|
|
|
|
|
|
|
if ($chapter) {
|
|
|
|
$listMessageData += [
|
|
|
|
$locale->trans('notifications.detail_chapter_name') => $chapter->name,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
$listMessageData += [
|
|
|
|
$locale->trans('notifications.detail_book_name') => $book->name,
|
|
|
|
$locale->trans('notifications.detail_created_by') => $this->user->name,
|
|
|
|
];
|
|
|
|
|
2023-09-17 23:20:21 +08:00
|
|
|
return $this->newMailMessage($locale)
|
|
|
|
->subject($locale->trans('notifications.new_page_subject', ['pageName' => $page->getShortName()]))
|
|
|
|
->line($locale->trans('notifications.new_page_intro', ['appName' => setting('app-name')], $locale))
|
2023-10-26 20:01:38 +08:00
|
|
|
->line(new ListMessageLine($listMessageData))
|
2023-09-17 23:20:21 +08:00
|
|
|
->action($locale->trans('notifications.action_view_page'), $page->getUrl())
|
|
|
|
->line($this->buildReasonFooterLine($locale));
|
2023-08-04 19:27:29 +08:00
|
|
|
}
|
|
|
|
}
|