30 lines
958 B
PHP
30 lines
958 B
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)
|
|
{
|
|
$inhaltsverzeichnis = Inhaltsverzeichnis::with('textblock_kennung')->get();
|
|
foreach ($inhaltsverzeichnis as $inhalt) {
|
|
ProjektInhaltsverzeichnis::updateOrCreate(
|
|
[
|
|
'projekte_id' => $record->id,
|
|
'name' => $inhalt->name,
|
|
],
|
|
[
|
|
'sort' => $inhalt->sort,
|
|
'ordnungszahl' => $inhalt->ordnungszahl,
|
|
'seite' => $inhalt->seite,
|
|
'textblock_kennung_id' => $inhalt->textblock_kennung_id,
|
|
'textblock' => Textblock::where('id', $inhalt->textblock_kennung_id)->pluck('textblock')->first(),
|
|
]);
|
|
}
|
|
}
|
|
}
|