Files
nutzwerte_fi4/app/Actions/Create/CreateProjektInhaltsverzeichnis.php
T
2025-10-23 12:07:56 +02:00

51 lines
1.6 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();
$part = 1;
foreach ($inhaltsverzeichnis as $inhalt) {
$textblock = '';
if ($inhalt->textblock_id > 0) {
$textblock = Textblock::where('id', $inhalt->textblock_id)->pluck('textblock')->first();
}
if ($inhalt->tabellen_id == 5) {
$part = 2;
}
ProjektInhaltsverzeichnis::updateOrCreate(
[
'projekte_id' => $record->id,
'name' => $inhalt->name,
],
[
'sort' => $inhalt->sort,
'ordnungszahl' => $inhalt->ordnungszahl,
'name' => $inhalt->name,
'name2' => $inhalt->name2,
'ueberschrift_anzeigen' => $inhalt->ueberschrift_anzeigen,
'tabellen_id' => $inhalt->tabellen_id,
'textblock_id' => $inhalt->textblock_id,
'part' => $part,
'seite' => $inhalt->seite,
'neue_seite' => $inhalt->neue_seite,
'seitenzahl_anzeige' => $inhalt->seitenzahl_anzeige,
'no_edit' => $inhalt->no_edit,
'textblock' => $textblock,
]);
}
}
}