Lae/app/Notifications/User/TodayIsUserBirthday.php

105 lines
2.6 KiB
PHP
Raw Normal View History

2022-12-30 12:55:45 +00:00
<?php
2023-01-13 14:11:56 +00:00
namespace App\Notifications\User;
2022-12-30 12:55:45 +00:00
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\URL;
class TodayIsUserBirthday extends Notification implements ShouldQueue
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
*
* @return array
*/
2023-01-10 13:42:27 +00:00
public function via(): array
2022-12-30 12:55:45 +00:00
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
*
* @return MailMessage
*/
2023-01-10 13:42:27 +00:00
public function toMail(): MailMessage
2022-12-30 12:55:45 +00:00
{
$url = URL::format(config('settings.dashboard.base_url'), config('settings.dashboard.birthday_path'));
$lyrics = [
[
2023-01-30 16:14:07 +00:00
'Happy Birthday',
'好想把我的心意传达给你。',
2022-12-30 12:55:45 +00:00
],
2022-12-30 13:01:47 +00:00
[
'今天祝你生日快乐!',
2022-12-30 12:55:45 +00:00
'这是第几次呢 假装忘记了(实际上)。',
2023-01-30 16:14:07 +00:00
'心里很清楚 只是在装傻。',
2022-12-30 12:55:45 +00:00
],
[
'今天祝你生日快乐!',
2023-01-30 16:14:07 +00:00
'蛋糕上的蜡烛要立几根好呢。连备用的都一起买好了!',
2022-12-30 12:55:45 +00:00
],
[
'Happy Birthday!',
2023-01-30 16:14:07 +00:00
'人与人的相遇真是不可思议。',
2022-12-30 12:55:45 +00:00
],
[
'你知道吗?',
'你对我而言很重要(一定要说出来)',
'会不会太迟了呢?我喜欢你,还会更喜欢你。',
],
[
2023-01-30 16:14:07 +00:00
'即使以心传心但也一定有着极限的。所以要好好地说出来。',
2022-12-30 12:55:45 +00:00
],
];
$lyric = $lyrics[array_rand($lyrics)];
$email = (new MailMessage)
2022-12-30 13:01:47 +00:00
->subject('生日快乐');
2022-12-30 12:55:45 +00:00
foreach ($lyric as $line) {
$email->line($line);
}
$email->line('生日快乐🎂')
->line('在生日当天,我们还为您提供了专属用户组,您可以前往仪表盘查看。')
->action('前往仪表盘', $url)
2023-01-30 16:14:07 +00:00
->line('感谢您继续使用 '.config('app.display_name').'。');
2022-12-30 12:55:45 +00:00
return $email;
}
/**
* Get the array representation of the notification.
*
*
* @return array
*/
2023-01-10 13:42:27 +00:00
public function toArray(): array
2022-12-30 12:55:45 +00:00
{
return [
//
];
}
}