gruene-seele/app/Mail/MailCheckout.php
2025-04-01 10:39:21 +02:00

89 lines
No EOL
3.2 KiB
PHP

<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Services\Util;
class MailCheckout extends Mailable
{
use Queueable, SerializesModels;
protected $txaction;
protected $shopping_order;
protected $shopping_payment;
protected $send_link;
protected $mode;
public $subject;
public $data;
public function __construct($txaction, $shopping_order, $shopping_payment, $send_link, $mode)
{
$this->txaction = $txaction;
$this->shopping_order = $shopping_order;
$this->shopping_payment = $shopping_payment;
$this->send_link = $send_link;
$this->mode = $mode;
if($this->txaction === 'paid'){
if($this->shopping_payment->clearingtype === 'non')
$this->subject = __('email.checkout_subject_non_paid')." ";
else{
$this->subject = __('email.checkout_subject_paid')." ";
}
}elseif($this->txaction === 'extern'){
$this->subject = __('email.checkout_subject_extern').": ";
$this->subject .= $shopping_order->member->account->m_first_name." ".$shopping_order->member->account->m_last_name." - ";
$this->subject .= $shopping_order->shopping_user->billing_firstname." ".$shopping_order->shopping_user->billing_lastname;
}else{
$this->subject = __('email.checkout_subject')." ";
}
/*if($shopping_order->user_shop){
$this->subject .= $shopping_order->user_shop->slug.".";
}*/
}
public function build()
{
$salutation = __('email.hello').",";
if($this->txaction !== 'extern' && $this->shopping_order->shopping_user){
$salutation = __('email.hello')." ".$this->shopping_order->shopping_user->billing_firstname.",";
//make Adresse
}
if($this->txaction === 'paid' || $this->txaction === 'extern'){
return $this->view('emails.checkout')->with([
'salutation' => $salutation,
'copy1line' => __('email.checkout_copy1line'),
'shopping_order' => $this->shopping_order,
'shopping_payment' => $this->shopping_payment,
'copy3line' => __('email.checkout_copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
'send_link' => $this->send_link,
'url' => Util::getMyUrl(),
'button' => Util::getMyUrl(false),
'mode' => $this->mode
]);
}else{
return $this->view('emails.checkout_status')->with([
'salutation' => $salutation,
'copy1line' => __('email.status_copy1line'),
'txaction' => $this->txaction,
'shopping_order' => $this->shopping_order,
'shopping_payment' => $this->shopping_payment,
'copy3line' => __('email.checkout_copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
'send_link' => false,
'mode' => $this->mode
]);
}
}
}