42 lines
1.4 KiB
PHP
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::orderBy('sort')->get();
|
|
|
|
foreach ($inhaltsverzeichnis as $key => $value) {
|
|
|
|
$key++;
|
|
$text = Textblock::where('id', $value->textblock_id)->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_verbergen = $value->ueberschrift_verbergen;
|
|
$inhalt->inhaltselement_id = $value->inhaltselement_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_name = $text->name ?? '';
|
|
$inhalt->textblock = $text->textblock ?? '';
|
|
$inhalt->textblock2 = $text->textblock2 ?? '';
|
|
$inhalt->save();
|
|
|
|
}
|
|
}
|
|
}
|