Files
nutzwerte_fi4/app/Actions/Create/CreateProjektInhaltsverzeichnis.php
T
2025-10-31 15:25:16 +01:00

46 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::orderBy('sort')->get();
foreach ($inhaltsverzeichnis as $key => $value) {
$key++;
$textblock = '';
if ($value->textblock_id > 0) {
$textblock = Textblock::where('id', $value->textblock_id)->pluck('textblock')->first();
}
$inhalt = new ProjektInhaltsverzeichnis;
$inhalt->projekte_id = $record->id;
$inhalt->sort = $key;
$inhalt->ordnungszahl = $value->ordnungszahl;
$inhalt->name = $value->name;
$inhalt->name2 = $value->name2;
$inhalt->ueberschrift_anzeigen = $value->ueberschrift_anzeigen;
$inhalt->tabellen_id = $value->tabellen_id;
$inhalt->textblock_id = $value->textblock_id;
$inhalt->part = $value->part;
$inhalt->seite = $value->seite;
$inhalt->neue_seite = $value->neue_seite;
$inhalt->seitenzahl_anzeige = $value->seitenzahl_anzeige;
$inhalt->no_edit = $value->no_edit;
$inhalt->textblock = $textblock;
$inhalt->save();
}
}
}