WechatNotificationChannel.php 702 Bytes
<?php

namespace App\Channels;

use App\Jobs\WechatTemplateMessageJob;
use App\Models\User;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Arr;

class WechatNotificationChannel
{
    public function send(User $notifiable, Notification $notification): void
    {
        // @phpstan-ignore-next-line
        $message = $notification->toWechat($notifiable);

        WechatTemplateMessageJob::dispatchSync(
            openId: Arr::get($message, 'openId', ''),
            template: Arr::get($message, 'template', ''),
            data: Arr::get($message, 'data', []),
            url: Arr::get($message, 'url', ''),
            page: Arr::get($message, 'page', '')
        );
    }
}