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/farmfun.komma.pro/app/Mail/SendProgramMail.php
<?php

namespace App\Mail;

use App\Komma\Locations\Models\Location;
use App\Komma\Orders\Models\Order;
use App\Komma\Orders\OrderService;
use App\Komma\ShoppingCart\Interfaces\ShoppingCartInterface;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class SendProgramMail extends Mailable
{
    use Queueable, SerializesModels;

    /** @var string */
    private $mailTo;

    /** @var Order */
    private $order;

    /** @var Location */
    private $location;

    /** @var Location */
    private $link;

    /** @var string */
    private $programUrl;

    /**
     * SendProgramMail constructor.
     *
     * @param ShoppingCartInterface $cart
     * @param string $mailTo
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function __construct(ShoppingCartInterface $cart, string $mailTo, string $cartGenerationLink)
    {
        /** @var OrderService $orderService */
        $orderService = app()->make(OrderService::class);
        $this->order = $orderService->createFakeOrderFromCart($cart);
        $this->location = $cart->getLocation();

        $this->link = $cartGenerationLink;

        $this->mailTo = $mailTo;
        $this->programUrl = 'https://farmfun.be/veelgestelde-vragen';
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $pdf = \PDF::loadView('pdf.program', ['order' => $this->order, 'location' => $this->location]);
        $pdf->stream('programma.pdf');

        return $this->view('emails.customer.sendProgram')
            ->to($this->mailTo)
            ->subject(__('site/email.send_program.subject').' | '.config('site.company.name'))
            ->attachData($pdf->output(), 'offerte-FarmFun.pdf', [
                'mime' => 'application/pdf',
            ])
            ->with([
                'order' => $this->order,
                'cartLink' => $this->link,
                'location' => $this->location,
                'programUrl' => $this->programUrl,
            ]);
    }
}