ActivitySingerSubmitWorkPassNotification.php 1.98 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 ActivitySingerSubmitWorkPassNotification 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.
     *
     * @return array
     */
    public function via(): array
    {
        return ['wechat', 'jPush'];
    }

    /**
     * @param \App\Models\User $notifiable
     * @return array
     */
    public function toJPush(User $notifiable): array
    {
        return [
            'user'    => $notifiable->getKey(),
            'title'   => '您的歌手成功达成合作',
            'content' => sprintf("您的歌手%s参与试唱活动《%s》达成合作", $this->work->getAttribute('user_nick_name'), $this->work->getAttribute('activity_name')),
            'data'    => ['type' => 'ToComplete', 'value' => $this->work->getAttribute('user_id')]
        ];
    }

    /**
     * @param \App\Models\User $notifiable
     * @return array
     */
    public function toWechat(User $notifiable): array
    {
        return [
            'openId'   => $notifiable->getWechatNotificationKey(),
            'template' => '-qM3dii-zb8nnvPunYDFyPmNptnKzdkgiWRH4-nK8vA',
            'page'     => 'packageMy/pages/myMember/detail?id=' . $this->work->getAttribute('activity_id'),
            'data'     => [
                'first'    => '恭喜,您的歌手成功达成合作',
                'keyword1' => $this->work->getUserFullName(),
                'keyword2' => '参与试唱《' . $this->work->getAttribute('activity_name') . '》达成合作',
                'remark'   => '点击查看 >'
            ]
        ];
    }
}