20-02-2026

This commit is contained in:
Kevin Adametz 2026-02-20 17:55:06 +01:00
parent a8b395e20d
commit a00c42e770
252 changed files with 28785 additions and 8907 deletions

View file

@ -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;
}
}
}