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->inhaltsverzeichnis_id = $value->id; $inhalt->sort = $key; $inhalt->ordnungszahl = $value->ordnungszahl; $inhalt->name = $value->name; $inhalt->ueberschrift_verbergen = $value->ueberschrift_verbergen; $inhalt->inhaltselement_id = $value->inhaltselement_id; $inhalt->textblock_id = $value->textblock_id; $inhalt->part = $value->part; $inhalt->seite = $value->seite; $inhalt->neue_seite = $value->neue_seite; $inhalt->no_edit = $value->no_edit; $inhalt->textblock_name = $text->name ?? ''; $inhalt->textblock = $text->textblock ?? ''; $inhalt->textblock2 = $text->textblock2 ?? ''; $inhalt->save(); } } }