HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/netwerkbrabant.komma.pro/app/Mail/Events/PaymentReceivedMail.php
<?php

namespace App\Mail\Events;

use App\KommaApp\Courses\Models\Course;
use App\KommaApp\Events\Models\Event;
use App\KommaApp\Orders\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Log;

class PaymentReceivedMail extends Mailable
{
    use Queueable, SerializesModels;

    private $order;
    private $model;
    private $siteUrl;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(Order $order)
    {
        $this->order = $order;
        $model = $this->order->products->first()->productable;
        $this->model = $model->load('translation', 'images');

        if(config('app.env') !== 'production') $this->siteUrl = 'http://netwerkbrabant.komma.pro';
        else $this->siteUrl = config('site.company.url');
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        Log::info(self::class.': Send');

        if(is_a($this->model, Event::class)) {
            $view = 'site.emails.events.paymentReceived';
            $subject = 'site/emails.events.paymentReceived';
        }
        elseif(is_a($this->model, Course::class)) {
            $view = 'site.emails.courses.paymentReceived';
            $subject = 'site/emails.courses.paymentReceived';
        }

        return $this->view($view)
            ->subject(trans($subject))
            ->to($this->order->email)
            ->with([
                'firstName' => $this->order->invoice_first_name,
                'lastName' => $this->order->invoice_last_name,
                'price' => $this->order->price,
                'model' => $this->model,
                'siteUrl' => $this->siteUrl,
            ]);
    }
}