File "OrderArtworkReminderNotification.php"

Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Notifications/OrderArtworkReminderNotification.php
File size: 1.79 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 OrderArtworkReminderNotification 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("Atrwork Reminder : Attachment path for Order No. " . $this->data['order_number']);
        $mailMessage = (new MailMessage)
            ->view('admin.mails.order_artwork_reminder', ['data' => $this->data])
            ->replyTo('orders@jmtrophies.com')
            ->subject("Your Artwork is Ready. ACTION REQUIRED ORDER NUMBER #{$this->data["order_number"]}");

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

        if (count($this->data["attachments"]) > 0) {
            foreach ($this->data["attachments"] as $attachment) {
                $mailMessage->attach($attachment);
                Log::channel('info_errors')->info($this->data["attachments"]);
            }
        }

        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, Your artwork for order #{$this->data["order_number"]} is ready to view. A proof has been sent to your email. Please check its contents and approve ASAP!");
        }
    }
}