mein-sterntours/app/Services/Booking.php
2026-04-22 16:01:27 +02:00

84 lines
2.6 KiB
PHP

<?php
namespace App\Services;
use App\Models\CMSContent;
use App\Models\CustomerMail;
class Booking
{
public static function contentFiles(): \Illuminate\Support\Collection
{
return CMSContent::where('identifier', '=', 'booking-email-file')
->get()
->sortByDesc('pos')
->pluck('slug', 'id');
}
public static function setOutputDirs(string $dir, ?string $subdir): void
{
MailDirService::setOutputDir($dir, $subdir);
}
/**
* @return string[]
*/
public static function getMailDirNotInOutput(int $bookingId, string $dir): array
{
$mails = CustomerMail::whereBookingId($bookingId)->whereDir($dir)->get();
return MailDirService::getMailDirsNotInOutput($mails, $dir);
}
public static function getCustomerMailDirs(): \Illuminate\Database\Eloquent\Collection
{
return MailDirService::getCustomerMailDirs();
}
public static function getCustomerMailDir(int $id): ?\App\Models\CMSContent
{
return MailDirService::getCustomerMailDir($id);
}
public static function getCustomerMailName(\App\Models\CMSContent $mailDir, ?int $mailDirId): string
{
return MailDirService::getCustomerMailName($mailDir, $mailDirId);
}
public static function getCustomerMailEmails(\App\Models\CMSContent $mailDir, ?int $mailDirId): array|string
{
return MailDirService::getCustomerMailEmails($mailDir, $mailDirId);
}
public static function getBookingInstructionPDFName(\App\Models\FewoLodging $fewo): string
{
return "HINWEISE-FERIENWOHNUNG-" . $fewo->pdf_name . ".pdf";
}
public static function getBookingCMSContent(\App\Models\CMSContent $content, string $identifier): \Illuminate\Database\Eloquent\Collection
{
return CMSContent::where('identifier', '=', $identifier)
->where('integer', $content->id)
->get()
->sortBy('pos');
}
public static function getBookingCMSContentForPDF(string $identifierContent, string $identifier): array
{
$pdfContent = [];
$contents = CMSContent::where('identifier', '=', $identifierContent)->get()->sortBy('pos');
foreach ($contents as $content) {
if ($content->decimal > 0) {
$pdfContent[] = $content;
}
foreach (self::getBookingCMSContent($content, $identifier) as $fewoContent) {
if ($fewoContent->decimal > 0) {
$pdfContent[] = $fewoContent;
}
}
}
return $pdfContent;
}
}