35 lines
892 B
PHP
35 lines
892 B
PHP
<?php
|
|
|
|
namespace App\Actions\Klone;
|
|
|
|
use App\Models\ProjektAllgemeinflaechen;
|
|
use App\Models\Projekte;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class KloneDokument
|
|
{
|
|
public static function clone($record)
|
|
{
|
|
$old_id = $record->id;
|
|
|
|
$insert_array = $record->toArray();
|
|
unset($insert_array['id']);
|
|
$insert_array['bezahlt_am'] = $record->bezahlt_am->format('Y-m-d H:i:s');
|
|
$insert_array['created_at'] = Carbon::now();
|
|
$insert_array['updated_at'] = Carbon::now();
|
|
|
|
$res = Projekte::insert($insert_array);
|
|
$new_id = $res->id;
|
|
|
|
dd($new_id);
|
|
|
|
$res = ProjektAllgemeinflaechen::where('projekt_id', $old_id)->get()->toArray();
|
|
foreach ($res as $row) {
|
|
unset($row['id']);
|
|
$row['projekt_id'] = $new_id;
|
|
ProjektAllgemeinflaechen::insert($row);
|
|
}
|
|
exit;
|
|
}
|
|
}
|