SmsNotificationChannel.php 499 Bytes
<?php

namespace App\Channels;

use App\Jobs\SmsMessageJob;
use App\Models\User;
use Arr;
use Illuminate\Notifications\Notification;

class SmsNotificationChannel
{
    public function send(User $notifiable, Notification $notification): void
    {
        // @phpstan-ignore-next-line
        $message = $notification->toSms($notifiable);
        $phone   = Arr::get($message, 'phone');
        $data    = Arr::get($message, 'data', []);

        SmsMessageJob::dispatchSync($phone, $data);
    }
}