alle geschoße bei pdf zusammenstellung aufführen

This commit is contained in:
salam committed 2026-05-20 07:58:31 +02:00
1 parent a2fc8d986f
commit 731a2d8aee
1 file changed
+25 -1
@@ -6,6 +6,7 @@ use App\Actions\Generate\PdfGenerator;
use App\Actions\Generate\Utilities\Format;
use App\Actions\Generate\Utilities\Html;
use App\Models\ProjektObjekte;
use App\Models\ProjektObjekteImDetail;
class Zusammenstellung
{
@@ -19,6 +20,8 @@ class Zusammenstellung
$html = Html::table_header(['Top', 'Geschoß', 'Orientierung', 'Typ', 'Nutzwert', 'x2 *', '%']);
$geschosse = self::loadGeschosse($projekte_id);
$objekte = ProjektObjekte::select()
->with('orientierung')
->with('projektobjekteimdetail')
@@ -31,7 +34,7 @@ class Zusammenstellung
$html .= '<tr>';
$html .= Html::td($objekt->top_nummer, 'bl bb br');
$html .= Html::td($objekt->projektobjekteimdetail->first()->geschoss, 'center br bb');
$html .= Html::td($geschosse[$objekt->id], 'center br bb');
$html .= Html::td($objekt->orientierung?->name, 'center br bb');
$html .= Html::td($objekt?->type, 'center br bb');
@@ -97,4 +100,25 @@ class Zusammenstellung
return $html;
}
public static function loadGeschosse($projekte_id)
{
$objekte = ProjektObjekteImDetail::where('projekte_id', $projekte_id)->get();
$arr = [];
foreach ($objekte as $objekt) {
$arr[$objekt->projekt_objekte_id][] = $objekt->geschoss;
}
foreach ($arr as $key => $value) {
$value = array_unique($value);
if (count($value) > 1) {
$arr[$key] = implode('/', $value);
} else {
$arr[$key] = (string) array_first($value);
}
}
return $arr;
}
}