Files
nutzwerte_fi4/app/Actions/Create/CreateProjektInhaltsverzeichnis.php
T
2025-10-20 11:51:00 +02:00

42 lines
1.4 KiB
PHP

<?php
namespace App\Actions\Create;
use App\Models\Inhaltsverzeichnis;
use App\Models\ProjektInhaltsverzeichnis;
use App\Models\Textblock;
class CreateProjektInhaltsverzeichnis
{
public static function create($record)
{
ProjektInhaltsverzeichnis::where('projekte_id', $record->id)->delete();
$inhaltsverzeichnis = Inhaltsverzeichnis::get();
foreach ($inhaltsverzeichnis as $inhalt) {
$textblock = '';
if ($inhalt->textblock_id > 0) {
$textblock = Textblock::where('id', $inhalt->textblock_id)->pluck('textblock')->first();
}
ProjektInhaltsverzeichnis::updateOrCreate(
[
'projekte_id' => $record->id,
'name' => $inhalt->name,
],
[
'sort' => $inhalt->sort,
'ordnungszahl' => $inhalt->ordnungszahl,
'name' => $inhalt->name,
'ueberschrift_nicht_anzeigen' => $inhalt->ueberschrift_nicht_anzeigen,
'tabellen_id' => $inhalt->tabellen_id,
'textblock_id' => $inhalt->textblock_id,
'seite' => $inhalt->seite,
'ohne_seitenzahl_anzeige' => $inhalt->ohne_seitenzahl_anzeige,
'textblock' => $textblock,
]);
}
}
}