HEX
Server: LiteSpeed
System: Linux sv4.hami.host 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User: armgroup (1008)
PHP: 8.2.32
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, mail, socket_create, socket_create_listen, socket_create_pair, link, dl, openlog, syslog, stream_socket_server, curl_multi_init
Upload Files
File: /home/armgroup/libs/app/Channels/SMSChannel.php
<?php

namespace App\Channels;

use App\FarazSms;
use Illuminate\Notifications\Notification;

class SMSChannel
{
    public function send($notifiable, Notification $notification)
    {
        $mobile = $notifiable->routeNotificationFor(SMSChannel::class, $notification) ?: $notifiable->mobile;
        $data = $notification->toSMS($notifiable);

        if (! app()->isProduction()) {
            info($mobile, $data);

            return;
        }
        
        if ($this->canSendMessage($data)) {
            try{
                send_sms($mobile,$data,$data['pattern']);
                \Log::alert('send sms with pattern.', ['pattern' => $data['pattern']]);
            } catch (\Exception $exception) {
                \Log::warning('not send sms with pattern.', ['pattern' => $data['pattern']]);
                    info($exception->getMessage());
            }
        }
        
    }
    // private function canSendMessage($data): bool
    // {
    //     return is_array($data) && count($data) >= 2 && array_key_exists('pattern', $data);
    // }
    
    private function canSendMessage($data): bool
    {
        return is_array($data) && count($data) == 4 && array_key_exists('var1', $data) && array_key_exists('var2', $data) && array_key_exists('var3', $data) && array_key_exists('pattern', $data);
    }
}