20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
|
|
@ -1,16 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Storage;
|
||||
use App\User;
|
||||
use App\Services\Credit;
|
||||
use App\Services\Invoice;
|
||||
use App\Models\UserCredit;
|
||||
use App\Models\ShoppingOrder;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Storage;
|
||||
|
||||
class MailCredit extends Mailable
|
||||
{
|
||||
|
|
@ -20,38 +16,65 @@ class MailCredit extends Mailable
|
|||
|
||||
public $subject;
|
||||
|
||||
|
||||
public function __construct(UserCredit $user_credit)
|
||||
{
|
||||
$this->user_credit = $user_credit;
|
||||
$this->subject = __('email.credit_title');
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$title = 'Hallo ';
|
||||
$title = 'Hallo ';
|
||||
$copy1line = __('email.credit_copy1line');
|
||||
|
||||
if(isset($this->user_credit->user->account)){
|
||||
$title .= $this->user_credit->user->account->m_first_name.",";
|
||||
if (isset($this->user_credit->user->account)) {
|
||||
$title .= $this->user_credit->user->account->m_first_name.',';
|
||||
}
|
||||
$filename = $this->user_credit->filename;
|
||||
$disk = $this->user_credit->disk;
|
||||
$path = $this->user_credit->getDownloadPath();
|
||||
|
||||
if (!Storage::disk($disk)->exists($path)) {
|
||||
$disk = $this->user_credit->disk;
|
||||
|
||||
// 1. Deutsches Original immer anhängen
|
||||
$pathDe = $this->user_credit->getDownloadPath();
|
||||
$filenameDe = $this->user_credit->filename;
|
||||
|
||||
if (! Storage::disk($disk)->exists($pathDe)) {
|
||||
return;
|
||||
}
|
||||
$file = Storage::disk($disk)->path($path);
|
||||
$file = str_replace('//', '/', $file);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
|
||||
return $this->view('emails.blank')->with([
|
||||
$fileDe = Storage::disk($disk)->path($pathDe);
|
||||
$fileDe = str_replace('//', '/', $fileDe);
|
||||
$mimeDe = Storage::disk($disk)->mimeType($pathDe);
|
||||
|
||||
$mail = $this->view('emails.blank')->with([
|
||||
'title' => $title,
|
||||
'copy1line' => $copy1line,
|
||||
])->attach($file,[
|
||||
'as' => $filename,
|
||||
'mime' => $mime,
|
||||
]); // attach file;
|
||||
'copy1line' => $copy1line,
|
||||
])->attach($fileDe, [
|
||||
'as' => $filenameDe,
|
||||
'mime' => $mimeDe,
|
||||
]);
|
||||
|
||||
// 2. Lokalisierte Version zusätzlich anhängen (wenn vorhanden und != DE)
|
||||
$locale = $this->user_credit->user
|
||||
? $this->user_credit->user->getLocale()
|
||||
: 'de';
|
||||
|
||||
if ($locale && $locale !== 'de') {
|
||||
$pathLocale = $this->user_credit->getDownloadPathLocale($locale);
|
||||
$filenameLocale = $this->user_credit->getFilenameLocale($locale);
|
||||
|
||||
// Nur anhängen wenn lokalisierte Version existiert und nicht gleich dem Original ist
|
||||
if (Storage::disk($disk)->exists($pathLocale) && $pathLocale !== $pathDe) {
|
||||
$fileLocale = Storage::disk($disk)->path($pathLocale);
|
||||
$fileLocale = str_replace('//', '/', $fileLocale);
|
||||
$mimeLocale = Storage::disk($disk)->mimeType($pathLocale);
|
||||
|
||||
$mail->attach($fileLocale, [
|
||||
'as' => $filenameLocale,
|
||||
'mime' => $mimeLocale,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $mail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\UserMessage;
|
||||
|
|
@ -6,20 +7,24 @@ use App\User;
|
|||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class MailCustomMessage extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected $data;
|
||||
protected $user;
|
||||
protected $sender;
|
||||
public $subject;
|
||||
public $message;
|
||||
public $message_last;
|
||||
protected $save;
|
||||
|
||||
protected $user;
|
||||
|
||||
protected $sender;
|
||||
|
||||
public $subject;
|
||||
|
||||
public $message;
|
||||
|
||||
public $message_last;
|
||||
|
||||
protected $save;
|
||||
|
||||
public function __construct(User $user, $data, $sender, $save = false)
|
||||
{
|
||||
|
|
@ -32,47 +37,45 @@ class MailCustomMessage extends Mailable
|
|||
$this->message_last = isset($data['message_last']) ? $data['message_last'] : '';
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('email.salutation').",";
|
||||
if($this->user->account){
|
||||
if($this->user->account->salutation === "mr"){
|
||||
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
|
||||
}else{
|
||||
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
|
||||
$salutation = __('email.salutation').',';
|
||||
if ($this->user->account) {
|
||||
if ($this->user->account->salutation === 'mr') {
|
||||
$salutation = __('email.dear_sir').' '.$this->user->account->first_name.',';
|
||||
} else {
|
||||
$salutation = __('email.dear_mrs').' '.$this->user->account->first_name.',';
|
||||
}
|
||||
}
|
||||
if($this->save){
|
||||
if ($this->save) {
|
||||
UserMessage::create([
|
||||
'user_id' => $this->user->id,
|
||||
'user_id' => $this->user->id,
|
||||
'send_user_id' => $this->sender->id,
|
||||
'email' => $this->user->email,
|
||||
'subject' => $this->subject,
|
||||
'message' => $this->message." ".$this->message_last,
|
||||
'message' => $this->message.' '.$this->message_last,
|
||||
'send' => true,
|
||||
'sent_at' => now(),
|
||||
]);
|
||||
}
|
||||
$url = "";
|
||||
$button = "";
|
||||
if(isset($this->data['confirmation_code'])){
|
||||
$url = '';
|
||||
$button = '';
|
||||
if (isset($this->data['confirmation_code'])) {
|
||||
$url = route('register_verify', $this->data['confirmation_code']);
|
||||
$button = __('email.button_account');
|
||||
|
||||
$button = __('email.button_account');
|
||||
}
|
||||
|
||||
if(isset($this->data['url'])){
|
||||
$url =$this->data['url'];
|
||||
$button = $this->data['button'];
|
||||
|
||||
if (isset($this->data['url'])) {
|
||||
$url = $this->data['url'];
|
||||
$button = $this->data['button'];
|
||||
}
|
||||
|
||||
return $this->view('emails.custom')->with([
|
||||
'url' => $url,
|
||||
'title' => $salutation,
|
||||
'button' => $button,
|
||||
'content' => $this->message,
|
||||
'content_last' => $this->message_last,
|
||||
'content' => $this->message,
|
||||
'content_last' => $this->message_last,
|
||||
'copy2line' => __('email.copy2line'),
|
||||
'copy3line' => __('email.copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Services\Invoice;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\UserInvoice;
|
||||
use Illuminate\Bus\Queueable;
|
||||
|
|
@ -14,39 +14,83 @@ class MailInvoice extends Mailable
|
|||
use Queueable, SerializesModels;
|
||||
|
||||
protected $shopping_order;
|
||||
|
||||
protected $user_invoice;
|
||||
|
||||
public $subject;
|
||||
|
||||
|
||||
public function __construct(ShoppingOrder $shopping_order, UserInvoice $user_invoice)
|
||||
{
|
||||
$this->shopping_order = $shopping_order;
|
||||
$this->user_invoice = $user_invoice;
|
||||
$this->subject = __('email.invoice_subject').': '.$shopping_order->getLastShoppingPayment('reference') ;
|
||||
|
||||
// Unterscheide zwischen Stornorechnung und normaler Rechnung
|
||||
$isCancellation = $user_invoice->cancellation && ! $user_invoice->cancellation_id;
|
||||
|
||||
if ($isCancellation) {
|
||||
$this->subject = __('email.cancellation_invoice_subject').': '.$shopping_order->getLastShoppingPayment('reference');
|
||||
} else {
|
||||
$this->subject = __('email.invoice_subject').': '.$shopping_order->getLastShoppingPayment('reference');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$title = __('email.invoice_title');
|
||||
$copy1line = __('email.invoice_copy1line').$this->shopping_order->getLastShoppingPayment('reference');
|
||||
// Unterscheide zwischen Stornorechnung und normaler Rechnung
|
||||
$isCancellation = $this->user_invoice->cancellation && ! $this->user_invoice->cancellation_id;
|
||||
|
||||
$filename = $this->user_invoice->filename;
|
||||
$disk = $this->user_invoice->disk;
|
||||
$path = $this->user_invoice->getDownloadPath();
|
||||
if (!Storage::disk($disk)->exists($path)) {
|
||||
if ($isCancellation) {
|
||||
$title = __('email.cancellation_invoice_title');
|
||||
$copy1line = __('email.cancellation_invoice_copy1line').$this->shopping_order->getLastShoppingPayment('reference');
|
||||
} else {
|
||||
$title = __('email.invoice_title');
|
||||
$copy1line = __('email.invoice_copy1line').$this->shopping_order->getLastShoppingPayment('reference');
|
||||
}
|
||||
|
||||
$disk = $this->user_invoice->disk;
|
||||
|
||||
// 1. Deutsches Original immer anhängen
|
||||
$pathDe = $this->user_invoice->getDownloadPath();
|
||||
$filenameDe = $this->user_invoice->filename;
|
||||
|
||||
if (! Storage::disk($disk)->exists($pathDe)) {
|
||||
return;
|
||||
}
|
||||
$file = Storage::disk($disk)->path($path);
|
||||
$file = str_replace('//', '/', $file);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
|
||||
return $this->view('emails.blank')->with([
|
||||
$fileDe = Storage::disk($disk)->path($pathDe);
|
||||
$fileDe = str_replace('//', '/', $fileDe);
|
||||
$mimeDe = Storage::disk($disk)->mimeType($pathDe);
|
||||
|
||||
$mail = $this->view('emails.blank')->with([
|
||||
'title' => $title,
|
||||
'copy1line' => $copy1line,
|
||||
])->attach($file,[
|
||||
'as' => $filename,
|
||||
'mime' => $mime,
|
||||
]); // attach file;
|
||||
'copy1line' => $copy1line,
|
||||
])->attach($fileDe, [
|
||||
'as' => $filenameDe,
|
||||
'mime' => $mimeDe,
|
||||
]);
|
||||
|
||||
// 2. Lokalisierte Version zusätzlich anhängen (wenn vorhanden und != DE)
|
||||
$locale = $this->shopping_order->shopping_user
|
||||
? $this->shopping_order->shopping_user->getLocale()
|
||||
: 'de';
|
||||
|
||||
if ($locale && $locale !== 'de') {
|
||||
$pathLocale = $this->user_invoice->getDownloadPathLocale($locale);
|
||||
$filenameLocale = $this->user_invoice->getFilenameLocale($locale);
|
||||
|
||||
// Nur anhängen wenn lokalisierte Version existiert und nicht gleich dem Original ist
|
||||
if (Storage::disk($disk)->exists($pathLocale) && $pathLocale !== $pathDe) {
|
||||
$fileLocale = Storage::disk($disk)->path($pathLocale);
|
||||
$fileLocale = str_replace('//', '/', $fileLocale);
|
||||
$mimeLocale = Storage::disk($disk)->mimeType($pathLocale);
|
||||
|
||||
$mail->attach($fileLocale, [
|
||||
'as' => $filenameLocale,
|
||||
'mime' => $mimeLocale,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $mail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue