File "PurchaseOrderMail.php"

Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Mail/PurchaseOrderMail.php
File size: 1.29 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class PurchaseOrderMail extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public $data;

    public function __construct($data)
    {
        $this->data = $data;
        $this->replyTo('purchasing@accordrg.com');
    }

    public function envelope()
    {
        if ($this->data['secondary_email'] != null) {
            return new Envelope(
                cc: $this->data['secondary_email'],
                subject: 'Purchase order mail from '.config('app.name')
            );
        } else {
            return new Envelope(
                subject: 'Purchase order mail from '.config('app.name'),
            );
        }
    }

    public function content()
    {
        return new Content(
            view: 'admin.mails.purchase_order',
        );
    }

    /**
     * Get the attachments for the message.
     *
     * @return array
     */
    public function attachments()
    {
        return [
            Attachment::fromPath($this->data['attachment_path']),
        ];
    }
}