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/Notifications/OrderSavedCustomer.php
<?php

namespace App\Notifications;

use App\Channels\SMSChannel;
use App\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class OrderSavedCustomer extends Notification implements ShouldQueue
{
    use Queueable;

    public $order;

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

    public function viaQueues()
    {
        return [
            'mail' => 'mail-queue',
            SMSChannel::class => 'sms-queue',
        ];
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        $available = [];
        if ($notifiable->email && $notifiable->email_verified_at) {
            array_push($available, 'mail');
        }
        if ($notifiable->mobile && (settings('order-registered-customer-sms') == 1)) {
            array_push($available, SMSChannel::class);
        }

        return $available;
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        $price = to_persian_numbers(number_format($this->order->price));
        $delivery_code = '';
        if ($this->order->delivery_code) {
            $delivery_code = "هنگام تحویل سفارش ارائه کد مقابل به پیک الزامی می‌باشد: {$this->order->delivery_code}";
        }

        return (new MailMessage)
            ->subject(__("اطلاعات سفارش {$this->order->tracking_code}"))
            ->line("سفارش شما با کد پیگیری {$this->order->tracking_code} به مبلغ {$price} تومان با موفقیت ثبت شد")
            ->line($delivery_code)
            ->action(__('جزئیات سفارش'), route('account.orders.show', $this->order->id));
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }

    public function toSMS($notifiable)
    {
        if ($this->order->delivery_code) {
            return [
                'var1' => (string) $this->order->user->name,
                'var2' => $this->order->tracking_code,
                'var3' => $this->order->delivery_code,
                'pattern' => '410816',
            ];
            // return [
            //     'tracking-code' => $this->order->tracking_code,
            //     'delivery-code' => $this->order->delivery_code,
            //     'pattern' => 'rw3k0rttm9p57gf',
            // ];
        }

        return [
            'var1' => (string) $this->order->user->name,
            'var2' => (string) $this->order->tracking_code,
            'var3' => '', 
            'pattern' => '410812',
        ];
    }
}