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,
]);
}
}