Files
nutzwerte_fi4/app/Actions/Generate/Tabellen/LadeProjekt.php
T

60 lines
2.0 KiB
PHP

<?php
namespace App\Actions\Generate\Tabellen;
use App\Models\ProjektObjekte;
use App\Models\ProjektObjekteImDetail;
class LadeProjekt
{
public static $methoden = [];
public static function project($projekte_id, $nicht_in_orientierung)
{
$objekte = ProjektObjekte::with('orientierung')
->where('projekte_id', $projekte_id)
->where('nicht_in_orientierung', $nicht_in_orientierung)
->orderBy('top_nummer')
->get();
$tmp = [];
foreach ($objekte as $objekt) {
$elemente = ProjektObjekteImDetail::with('methode')->where('projekt_objekte_id', $objekt->id)->get();
foreach ($elemente as $key => $element) {
$methode_id = $element->methode->methode_id;
$methode_name = $element->methode->raumart;
$methode_faktor = $element->methode->faktor;
$methode_aufstellung_id = $element->methode->aufstellung_id;
$orientierung = $objekt['orientierung']['name'] ?? '';
if ($key > 0 && $methode_id == 1) {
$orientierung = '';
}
$geschoss = $element['geschoss'] ?? '';
if ($key > 0 && $methode_id <= 1) {
$geschoss = '';
}
$t = [];
$t['id'] = $objekt->id;
$t['type'] = ! $key ? $objekt->type : '';
$t['geschoss'] = $geschoss;
$t['orientierung'] = $orientierung;
$t['raumart'] = $methode_name;
$t['flaeche'] = $element['flaeche'];
$t['nutzwert'] = $element['nutzwert'];
$t['top_nummer'] = ! $key ? $objekt->top_nummer : '';
$t['objekt_nutzwert'] = $objekt->nutzwert;
$t['faktor'] = $methode_faktor;
$t['aufstellung_id'] = $methode_aufstellung_id;
$tmp[$objekt->top_nummer][$methode_id][] = $t;
}
}
return $tmp;
}
}