File "OrderApprovedConfirmedNotification.php"

Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Notifications/OrderApprovedConfirmedNotification.php
File size: 1.7 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Notifications;

use App\Channels\Messages\SMS;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;

class OrderApprovedConfirmedNotification extends Notification implements ShouldQueue
{
    use Queueable;
    public $data;

    public function __construct($data)
    {
        $this->data = $data;
    }

    public function via($notifiable)
    {
        return ['mail', 'sms'];
    }

    public function toMail($notifiable)
    {
        Log::channel('info_errors')->info("Payment Reminder : Invoice path for Order No. " . $this->data['order_number']);
        Log::channel('info_errors')->info($this->data['invoice_path']);

        $mailMessage = (new MailMessage)
            ->view('admin.mails.order_approved_confirmed', ['data' => $this->data])
            ->replyTo('orders@jmtrophies.com')
            ->subject("ORDER ACKNOWLEDGMENT #{$this->data["order_number"]} - Please Review")
            ->attach($this->data['invoice_path']);

        if (!empty($notifiable->secondary_email)) {
            $mailMessage->cc($notifiable->secondary_email);
        }

        return $mailMessage;
    }

    public function toSms($notifiable)
    {
        if (!empty($notifiable->phone_number) && $notifiable->sms_notification == 1) {
            return (new SMS)
                ->content("Hi it's J&M Trophies, Thank you for your Order #{$this->data["order_number"]} with J&M Trophies, inc.! Please keep a close eye on your email for order updates!");
        }
    }

    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}