File: D:/HostingSpaces/SBogers10/farmfun.komma.pro/app/Mail/OrderReceivedAdminMail.php
<?php
namespace App\Mail;
use App\Komma\Locations\Models\Location;
use App\Komma\Orders\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class OrderReceivedAdminMail extends Mailable
{
use Queueable, SerializesModels;
/** @var Order */
private $order;
/** @var Location */
private $location;
/** @var array */
private $sendTo;
public bool $savedToTeamleader;
public array $messages;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(Order $order, Location $location, bool $savedToTeamleader, array $messages)
{
$this->order = $order;
$this->location = $location;
$this->savedToTeamleader = $savedToTeamleader;
$this->messages = $messages;
// location determines the email address, not site.
// $sendTo = ($location->country === 'BE' ? ['info@farmfun.be'] : ['info@farmfun.nl']);
$sendTo = ($location->country === 'BE' ? ['mark+be@komma.nl'] : ['mark+nl@komma.nl']);
if (! in_array($location->email, $sendTo)) {
$sendTo[] = $location->email;
}
// Log::warning(self::class . ': Mailed to; ' . site_config('mailTo') . ' en ' . $location->email);
// Log::info(config('mail'));
// Log::info('');
$this->sendTo = $sendTo;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.admin.orderReceived')
->to($this->sendTo)
->subject($this->order->order_reservation_number.' | '.__('site/email.order_received_admin.subject').' | '.config('site.company.name'))
->with([
'order' => $this->order,
'location' => $this->location,
]);
}
}