ActivitySubmitWorkRejectNotification.php 1.26 KB
<?php

namespace App\Notifications;

use App\Models\User;
use App\Models\Views\ActivityWork;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class ActivitySubmitWorkRejectNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public ActivityWork $work;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(ActivityWork $work)
    {
        $this->work = $work;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param mixed $notifiable
     * @return array
     */
    public function via(): array
    {
        return ['sms'];
    }

    /**
     * @param \App\Models\User $notifiable
     * @return array
     */
    public function toSms(User $notifiable): array
    {
        return [
            'phone' => $notifiable->getPhoneNotificationKey(),
            'data'  => [
                'template' => 'SMS_462415223',
                'content'  => '感谢您参与试唱《${song_name}》,很遗憾暂未能成合作。欢迎您前往海星试唱尝试更多歌曲。',
                'data'     => ['song_name' => $this->work->getAttribute('activity_name')]
            ]
        ];
    }
}