diff --git a/app/Actions/Cloning/CloneProjekt.php b/app/Actions/Cloning/CloneProjekt.php index aaac6c3..8c7e4f9 100644 --- a/app/Actions/Cloning/CloneProjekt.php +++ b/app/Actions/Cloning/CloneProjekt.php @@ -28,25 +28,26 @@ class CloneProjekt * projekt_objekte_im_details * projekt_objektes */ - $news_project = $record->replicate(); - $news_project->cloned_from_id = $record->id; - $news_project->save(); + $NEW = $record->replicate(); + $NEW->cloned_from_id = $record->id; + $NEW->save(); - ProjektUser::create(['user_id' => Auth::user()->id, 'projekte_id' => $news_project->id, 'evaluation_gutachten' => 0]); + ProjektUser::create(['user_id' => Auth::user()->id, 'projekte_id' => $NEW->id, 'evaluation_gutachten' => 0]); $res = ProjektObjekte::where('projekte_id', $record->id)->get(); + foreach ($res as $row) { $new = $row->replicate(); - $new->projekte_id = $news_project->id; - $new->projekte_cloned_from_id = $row->id; + $new->projekte_id = $NEW->id; + $new->cloned_from_id = $row->id; $new->save(); $res2 = ProjektObjekteImDetail::where('projekte_id', $record->id)->where('projekt_objekte_id', $row->id)->get(); foreach ($res2 as $row2) { $new2 = $row2->replicate(); - $new2->projekte_id = $news_project->id; + $new2->projekte_id = $NEW->id; $new2->projekt_objekte_id = $new->id; - $new2->projekte_objekte_cloned_from_id = $row2->id; + $new2->cloned_from_id = $row2->id; $new2->save(); } } @@ -54,37 +55,40 @@ class CloneProjekt $res = ProjektAllgemeinflaechen::where('projekte_id', $record->id)->get(); foreach ($res as $row) { $new = $row->replicate(); - $new->projekte_id = $news_project->id; + $new->projekte_id = $NEW->id; + $new->cloned_from_id = $row->id; $new->save(); } + $res = ProjektInhaltsverzeichnis::where('projekte_id', $record->id)->get(); foreach ($res as $row) { $new = $row->replicate(); - $new->projekte_id = $news_project->id; - $new->save(); - } - $res = ProjektPlatzhalter::where('projekte_id', $record->id)->get(); - foreach ($res as $row) { - $new = $row->replicate(); - $new->projekte_id = $news_project->id; + $new->projekte_id = $NEW->id; + $new->cloned_from_id = $row->id; $new->save(); } + $res = ProjektMerkmale::where('projekte_id', $record->id)->get(); foreach ($res as $row) { $new = $row->replicate(); - $new->projekte_id = $news_project->id; + $new->projekte_id = $NEW->id; + $new->cloned_from_id = $row->id; $new->save(); } + $res = ProjektMethode::where('projekte_id', $record->id)->get(); foreach ($res as $row) { $new = $row->replicate(); - $new->projekte_id = $news_project->id; + $new->projekte_id = $NEW->id; + $new->cloned_from_id = $row->id; $new->save(); } + $res = ProjektPlatzhalter::where('projekte_id', $record->id)->get(); foreach ($res as $row) { $new = $row->replicate(); - $new->projekte_id = $news_project->id; + $new->projekte_id = $NEW->id; + $new->cloned_from_id = $row->id; $new->save(); } } diff --git a/app/Actions/Cloning/Reparieren.php b/app/Actions/Cloning/Reparieren.php index e7b024d..7f60f84 100644 --- a/app/Actions/Cloning/Reparieren.php +++ b/app/Actions/Cloning/Reparieren.php @@ -10,6 +10,7 @@ use App\Models\ProjektMethode; use App\Models\ProjektObjekte; use App\Models\ProjektObjekteImDetail; use App\Models\ProjektPlatzhalter; +use Filament\Notifications\Notification; class Reparieren { @@ -26,79 +27,130 @@ class Reparieren * projekt_objekte_im_details * projekt_objektes */ - $ORIGINAL = $record->cloned_from_id; - $GEKLONT = $record->id; + $CLONED_FROM_ID = $record->cloned_from_id; + $ACTIVE_ID = $record->id; - if($ORIGINAL){ - // überprüfe geklontes Projekt! - $originals = ProjektObjekte::where('projekte_id', $ORIGINAL)->get(); + /** + * Ist geklonet + */ + if($CLONED_FROM_ID){ + + // Lösche alle geklonten "Objekte" ohne Verbindung zu Original + ProjektObjekte::where('projekte_id', $ACTIVE_ID)->where('cloned_from_id', 0)->where('added_manuel', 0)->delete(); + + // Überprüfe geklontes Projekt + $originals = ProjektObjekte::where('projekte_id', $CLONED_FROM_ID)->get(); foreach ($originals as $original) { - $check = ProjektObjekte::where('projekte_id', $GEKLONT)->where('top_nummer', $original->top_nummer)->get(); - dd($check); + $check = ProjektObjekte::where('projekte_id', $ACTIVE_ID)->where('cloned_from_id', $original->id)->get(); if (! $check) { /** - * Im original dazugekommen + * Im Original dazugekommen oder gelöscht */ $new = $original->replicate(); - $new->projekte_id = $GEKLONT; + $new->projekte_id = $ACTIVE_ID; + $new->cloned_from_id = $CLONED_FROM_ID; $new->save(); - $res2 = ProjektObjekteImDetail::where('projekte_id', $ORIGINAL)->where('projekt_objekte_id', $original->id)->get(); + // Lösche alle geklonten "Objekte im Detail" ohne Verbindung zu Original + ProjektObjekteImDetail::where('projekte_id', $ACTIVE_ID)->where('cloned_from_id', 0)->where('added_manuel', 0)->delete(); + + $res2 = ProjektObjekteImDetail::where('projekte_id', $CLONED_FROM_ID)->where('projekt_objekte_id', $original->id)->get(); foreach ($res2 as $row2) { - $check = ProjektObjekteImDetail::where('projekte_id', $GEKLONT)->where('raumart', $row2->raumart)->first(); + $check = ProjektObjekteImDetail::where('projekte_id', $ACTIVE_ID)->where('raumart', $row2->raumart)->first(); if (! $check) { $new2 = $row2->replicate(); - $new2->projekte_id = $GEKLONT; + $new2->projekte_id = $ACTIVE_ID; $new2->projekt_objekte_id = $new->id; + $new2->cloned_from_id = $row2->id; $new2->save(); } } } } + + ProjektAllgemeinflaechen::where('projekte_id', $ACTIVE_ID)->where('cloned_from_id', 0)->where('added_manuel', 0)->delete(); + $res = ProjektAllgemeinflaechen::where('projekte_id', $CLONED_FROM_ID)->get(); + foreach ($res as $row) { + $check = ProjektAllgemeinflaechen::where('projekte_id', $ACTIVE_ID)->where('raumart', $original->raumart)->first(); + if (! $check) { + $new = $row->replicate(); + $new->projekte_id = $ACTIVE_ID; + $new->cloned_from_id = $row->id; + $new->save(); + } + } + + ProjektInhaltsverzeichnis::where('projekte_id', $ACTIVE_ID)->where('cloned_from_id', 0)->where('added_manuel', 0)->delete(); + $res = ProjektInhaltsverzeichnis::where('projekte_id', $CLONED_FROM_ID)->get(); + foreach ($res as $row) { + $check = ProjektInhaltsverzeichnis::where('projekte_id', $ACTIVE_ID)->where('inhaltsverzeichnis_id', $original->inhaltsverzeichnis_id)->first(); + if (! $check) { + $new = $row->replicate(); + $new->projekte_id = $ACTIVE_ID; + $new->cloned_from_id = $row->id; + $new->save(); + } + } + + ProjektMerkmale::where('projekte_id', $ACTIVE_ID)->where('cloned_from_id', 0)->where('added_manuel', 0)->delete(); + $res = ProjektMerkmale::where('projekte_id', $record->id)->get(); + foreach ($res as $row) { + $check = ProjektInhaltsverzeichnis::where('projekte_id', $ACTIVE_ID)->where('name', $original->name)->first(); + if (! $check) { + $new = $row->replicate(); + $new->projekte_id = $ACTIVE_ID; + $new->cloned_from_id = $row->id; + $new->save(); + } + } + + $res = ProjektMethode::where('projekte_id', $record->id)->get(); + foreach ($res as $row) { + $new = $row->replicate(); + $new->projekte_id = $record->id; + $new->cloned_from_id = $row->id; + $new->save(); + } + + $res = ProjektPlatzhalter::where('projekte_id', $record->id)->get(); + foreach ($res as $row) { + $new = $row->replicate(); + $new->projekte_id = $record->id; + $new->cloned_from_id = $row->id; + $new->save(); + } } - // $res = ProjektAllgemeinflaechen::where('projekte_id', $original_id)->get(); - // foreach ($res as $row) { - // $check = ProjektInhaltsverzeichnis::where('projekte_id', $original_id)->where('raumart', $original->raumart)->first(); - // if (! $check) { - // $new = $row->replicate(); - // $new->projekte_id = $record->id; - // $new->save(); - // } - // } + // OBJEKTE IM DETAIL ZU OBJEKTE + // Kontrolliere Verbindungen geklonter und nicht geklonter + // Select all childreen from project + $res = ProjektObjekteImDetail::select('projekt_objekte_id')->where('projekte_id', $ACTIVE_ID)->groupBy('projekt_objekte_id')->get(); + foreach ($res as $row) { + // See if parent exists + $res2 = ProjektObjekte::where('projekte_id', $ACTIVE_ID)->where('id', $row->projekt_objekte_id)->first(); + if(!$res){ + // If parent NOT exists delete all childreen + ProjektObjekteImDetail::where('projekte_id', $ACTIVE_ID)->where('projekt_objekte_id', $row->projekt_objekte_id)->delete(); + } + } + // OBJEKTE ZU OBJEKTE IM DETAIL + $res = ProjektObjekte::where('projekte_id', $ACTIVE_ID)->get(); + foreach ($res as $row) { + // See if cildreen exists + $res2 = ProjektObjekteImDetail::where('projekte_id', $ACTIVE_ID)->where('projekt_objekte_id', $row->id)->first(); + if(!$res){ + // If childree NOT exists delete parent + ProjektObjekte::where('id', $row->id)->delete(); + } + } + + Notification::make() + ->title('Projekt reparieren') + ->body('Die Reparatur des Projektes war erfolgreich.') + ->icon('heroicon-o-exclamation-triangle') + ->duration(10000) + ->success() + ->send(); - // $res = ProjektInhaltsverzeichnis::where('projekte_id', $original_id)->get(); - // foreach ($res as $row) { - // $check = ProjektInhaltsverzeichnis::where('projekte_id', $original_id)->where('top_nummer', $original->top_nummer)->first(); - // if (! $check) { - // $new = $row->replicate(); - // $new->projekte_id = $record->id; - // $new->save(); - // } - // } - // $res = ProjektPlatzhalter::where('projekte_id', $record->id)->get(); - // foreach ($res as $row) { - // $new = $row->replicate(); - // $new->projekte_id = $record->id; - // $new->save(); - // } - // $res = ProjektMerkmale::where('projekte_id', $record->id)->get(); - // foreach ($res as $row) { - // $new = $row->replicate(); - // $new->projekte_id = $record->id; - // $new->save(); - // } - // $res = ProjektMethode::where('projekte_id', $record->id)->get(); - // foreach ($res as $row) { - // $new = $row->replicate(); - // $new->projekte_id = $record->id; - // $new->save(); - // } - // $res = ProjektPlatzhalter::where('projekte_id', $record->id)->get(); - // foreach ($res as $row) { - // $new = $row->replicate(); - // $new->projekte_id = $record->id; - // $new->save(); - // } } } diff --git a/app/Actions/Validation/GutachtenValidation.php b/app/Actions/Validation/GutachtenValidation.php index 764027b..3a86fff 100644 --- a/app/Actions/Validation/GutachtenValidation.php +++ b/app/Actions/Validation/GutachtenValidation.php @@ -9,8 +9,8 @@ use App\Models\ProjektInhaltsverzeichnis; use App\Models\ProjektMethode; use App\Models\ProjektObjekte; use App\Models\ProjektObjekteImDetail; -// use App\Models\ProjektPlatzhalter; use Filament\Notifications\Notification; +use Illuminate\Support\Facades\Auth; class GutachtenValidation { @@ -24,7 +24,7 @@ class GutachtenValidation /** * Gutachter */ - $res = Gutachter::where('konto_id', auth()->user()->konto_id)->where('id', $pro->gutachter_id)->first(); + $res = Gutachter::where('konto_id', Auth::user()->konto_id)->where('id', $pro->gutachter_id)->first(); if (! $res->digitale_signatur_stempel) { Notification::make() ->title('Gutacher') diff --git a/app/Filament/Resources/Projektes/Pages/EditProjekte.php b/app/Filament/Resources/Projektes/Pages/EditProjekte.php index 17a7b88..b99a63b 100644 --- a/app/Filament/Resources/Projektes/Pages/EditProjekte.php +++ b/app/Filament/Resources/Projektes/Pages/EditProjekte.php @@ -155,7 +155,7 @@ class EditProjekte extends EditRecord ->color('success') ->label('Daten reparieren') ->modalIcon('phosphor-arrow-fat-line-right-fill') - ->modalDescription( new HtmlString('
  1. Bei geklonten Projekten werden Änderungen vom originalen Objekt und Objekt im Detail übernommen.
  2. Bei geklonten Projekten werden gelöschte Objekt und Objekt im Detail ergänzt.
  3. Objekt im Detail ohne Verbindung zum Objekt werden gelöscht.
  4. Doppelte Objekt oder Objekt im Detail werden gelöscht.
')) + ->modalDescription( self::reparierenText()) // ->hidden(fn ($record): bool => ! $record->cloned_from_id) ->action(fn ($record) => Reparieren::run($record)) ->icon('phosphor-arrow-fat-line-right-fill'), @@ -173,4 +173,23 @@ class EditProjekte extends EditRecord { return 'Projekt Änderungen gespeichert'; } + + protected function reparierenText(): ?HtmlString + { + $txt = '
Geklonte Projekte
'; + $txt .= '
    '; + $txt .= '
  1. Es werden Änderungen vom originalen Objekt und Objekt im Detail übernommen.
  2. '; + $txt .= '
  3. Es werden gelöschte Objekt und Objekt im Detail ergänzt.
  4. '; + $txt .= '
  5. Elemente ohne Verbindung zum Originale werden gelöscht.
  6. '; + $txt .= '
'; + $txt .= '
Alle Projekte
'; + $txt .= '
    '; + $txt .= '
  1. Objekt ohne verbundene Objekt im Detail werden gelöscht.
  2. '; + $txt .= '
  3. Objekt im Detail ohne Verbindung zu einem Objekt werden gelöscht.
  4. '; + $txt .= '
  5. Manuell hinzugefügte Elemente werden nicht gelöscht.
  6. '; + // $txt .= '
  7. Doppelte Objekt oder Objekt im Detail werden gelöscht.
  8. '; + $txt .= '
'; + + return new HtmlString($txt); + } } diff --git a/app/Filament/Resources/Projektes/RelationManagers/ProjektAllgemeinflaechensRelationManager.php b/app/Filament/Resources/Projektes/RelationManagers/ProjektAllgemeinflaechensRelationManager.php index a323b8a..ebd275f 100644 --- a/app/Filament/Resources/Projektes/RelationManagers/ProjektAllgemeinflaechensRelationManager.php +++ b/app/Filament/Resources/Projektes/RelationManagers/ProjektAllgemeinflaechensRelationManager.php @@ -10,6 +10,7 @@ use Filament\Actions\CreateAction; use Filament\Actions\DeleteAction; use Filament\Actions\DeleteBulkAction; use Filament\Actions\EditAction; +use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Filament\Notifications\Notification; @@ -37,6 +38,7 @@ class ProjektAllgemeinflaechensRelationManager extends RelationManager { return $schema ->components([ + Hidden::make('added_manuel')->default(1), TextInput::make('geschoss') ->required() ->maxLength(255), diff --git a/app/Filament/Resources/Projektes/RelationManagers/ProjektInhaltsverzeichnisRelationManager.php b/app/Filament/Resources/Projektes/RelationManagers/ProjektInhaltsverzeichnisRelationManager.php index 96a4f62..db03269 100644 --- a/app/Filament/Resources/Projektes/RelationManagers/ProjektInhaltsverzeichnisRelationManager.php +++ b/app/Filament/Resources/Projektes/RelationManagers/ProjektInhaltsverzeichnisRelationManager.php @@ -14,6 +14,7 @@ use Filament\Actions\DeleteAction; use Filament\Actions\DeleteBulkAction; use Filament\Actions\EditAction; use Filament\Forms\Components\Checkbox; +use Filament\Forms\Components\Hidden; use Filament\Forms\Components\RichEditor; use Filament\Forms\Components\RichEditor\RichContentRenderer; use Filament\Forms\Components\Select; @@ -32,6 +33,7 @@ use Filament\Tables\Enums\FiltersLayout; use Filament\Tables\Filters\Filter; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Facades\Auth; use ToneGabes\BetterOptions\Forms\Components\RadioCards; use ToneGabes\Filament\Icons\Enums\Phosphor; @@ -53,6 +55,7 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager ->components([ Tabs::make('Tabs') ->tabs([ + Hidden::make('added_manuel')->default(1), Tab::make('Überschrift') ->schema([ Checkbox::make('neue_seite') @@ -157,7 +160,7 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager // $record = $mountedActions[0]->getRawData(); // $block = new KontoTextblock; - // $block->konto_id = auth()->user()->konto_id; + // $block->konto_id = Auth::user()->konto_id; // $block->name = $data['name']; // $block->textblock = RichContentRenderer::make($record['textblock'])->toHtml(); // $block->save(); @@ -171,7 +174,7 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager // Select::make('konto_textblock_id') // ->hiddenLabel() // ->searchable() - // ->options(KontoTextblock::where('konto_id', auth()->user()->konto_id)->pluck('name', 'id')) + // ->options(KontoTextblock::where('konto_id', Auth::user()->konto_id)->pluck('name', 'id')) // ->belowLabel([ // 'Bitte eine Vorlage auswählen', // ]), @@ -270,7 +273,7 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager $record = $mountedActions[0]->getRawData(); $block = new KontoTextblock; - $block->konto_id = auth()->user()->konto_id; + $block->konto_id = Auth::user()->konto_id; $block->name = $data['name']; $block->textblock = RichContentRenderer::make($record['textblock'])->toHtml(); $block->save(); @@ -284,7 +287,7 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager Select::make('konto_textblock_id') ->hiddenLabel() ->searchable() - ->options(KontoTextblock::where('konto_id', auth()->user()->konto_id)->pluck('name', 'id')) + ->options(KontoTextblock::where('konto_id', Auth::user()->konto_id)->pluck('name', 'id')) ->belowLabel([ 'Bitte eine Vorlage auswählen', ]), diff --git a/app/Filament/Resources/Projektes/RelationManagers/ProjektMethodesRelationManager.php b/app/Filament/Resources/Projektes/RelationManagers/ProjektMethodesRelationManager.php index 0a62295..842f3d0 100644 --- a/app/Filament/Resources/Projektes/RelationManagers/ProjektMethodesRelationManager.php +++ b/app/Filament/Resources/Projektes/RelationManagers/ProjektMethodesRelationManager.php @@ -12,6 +12,7 @@ use Filament\Actions\BulkAction; use Filament\Actions\BulkActionGroup; use Filament\Actions\DeleteAction; use Filament\Actions\EditAction; +use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Notifications\Notification; diff --git a/app/Filament/Resources/Projektes/RelationManagers/ProjektPlatzhalterRelationManager.php b/app/Filament/Resources/Projektes/RelationManagers/ProjektPlatzhalterRelationManager.php index 9791d33..02d7d71 100644 --- a/app/Filament/Resources/Projektes/RelationManagers/ProjektPlatzhalterRelationManager.php +++ b/app/Filament/Resources/Projektes/RelationManagers/ProjektPlatzhalterRelationManager.php @@ -4,6 +4,7 @@ namespace App\Filament\Resources\Projektes\RelationManagers; use App\Actions\Create\CreatePlatzhalter; use Filament\Actions\Action; +use Filament\Forms\Components\Hidden; use Filament\Forms\Components\TextInput; use Filament\Resources\RelationManagers\RelationManager; use Filament\Schemas\Schema; @@ -27,6 +28,7 @@ class ProjektPlatzhalterRelationManager extends RelationManager { return $schema ->components([ + Hidden::make('added_manuel')->default(1), TextInput::make('platzhalter') ->required() ->maxLength(255), diff --git a/app/Filament/Resources/Projektes/Tables/ProjektesTable.php b/app/Filament/Resources/Projektes/Tables/ProjektesTable.php index 67f5418..5ce554d 100644 --- a/app/Filament/Resources/Projektes/Tables/ProjektesTable.php +++ b/app/Filament/Resources/Projektes/Tables/ProjektesTable.php @@ -29,12 +29,12 @@ class ProjektesTable ->columns([ TextColumn::make('id')->sortable(), ToggleColumn::make('meine') - ->state(fn ($record) => ProjektUser::where('user_id', auth()->user()->id)->where('projekte_id', $record->id)->count()) + ->state(fn ($record) => ProjektUser::where('user_id', Auth::user()->id)->where('projekte_id', $record->id)->count()) ->beforeStateUpdated(function ($record, $state) { if ($state) { - ProjektUser::create(['user_id' => auth()->user()->id, 'projekte_id' => $record->id]); + ProjektUser::create(['user_id' => Auth::user()->id, 'projekte_id' => $record->id]); } else { - ProjektUser::where('user_id', auth()->user()->id)->where('projekte_id', $record->id)->delete(); + ProjektUser::where('user_id', Auth::user()->id)->where('projekte_id', $record->id)->delete(); } }), TextColumn::make('interner_name') @@ -71,7 +71,7 @@ class ProjektesTable $data['meine'], function (Builder $query, $meine) { $query->whereHas('projekt_users', function ($query) { - $query->where('projekt_users.user_id', auth()->user()->id); + $query->where('projekt_users.user_id', Auth::user()->id); }); } ); diff --git a/app/Models/ProjektObjekte.php b/app/Models/ProjektObjekte.php index fd446e2..437e3c7 100644 --- a/app/Models/ProjektObjekte.php +++ b/app/Models/ProjektObjekte.php @@ -10,7 +10,7 @@ class ProjektObjekte extends Model { protected $fillable = [ 'projekte_id', - 'projekte_cloned_from_id', + 'cloned_from_id', 'orientierung_id', 'nicht_in_orientierung', 'top_nummer', diff --git a/app/Models/ProjektObjekteImDetail.php b/app/Models/ProjektObjekteImDetail.php index 0186f1e..66d7746 100644 --- a/app/Models/ProjektObjekteImDetail.php +++ b/app/Models/ProjektObjekteImDetail.php @@ -9,7 +9,7 @@ class ProjektObjekteImDetail extends Model protected $fillable = [ 'projekte_id', 'projekt_objekte_id', - 'projekte_objekte_cloned_from_id', + 'cloned_from_id', 'methode_id', 'top_nummer', 'geschoss', diff --git a/database/migrations/2025_09_24_131440_create_projektes_table.php b/database/migrations/2025_09_24_131440_create_projektes_table.php index 1196aab..6eabfd5 100644 --- a/database/migrations/2025_09_24_131440_create_projektes_table.php +++ b/database/migrations/2025_09_24_131440_create_projektes_table.php @@ -13,10 +13,10 @@ return new class extends Migration { Schema::create('projektes', function (Blueprint $table) { $table->id(); + $table->integer('cloned_from_id')->default(0)->nullable(); $table->foreignId('konto_id')->constrained(); $table->foreignId('auftraggeber_id')->constrained(); $table->foreignId('gutachter_id')->constrained(); - $table->integer('cloned_from_id')->default(0); $table->string('interner_name'); $table->string('offizieller_name')->nullable(); $table->string('ort')->nullable(); diff --git a/database/migrations/2025_10_03_154046_create_allgemeinflaechens_table.php b/database/migrations/2025_10_03_154046_create_projekt_allgemeinflaechens_table.php similarity index 85% rename from database/migrations/2025_10_03_154046_create_allgemeinflaechens_table.php rename to database/migrations/2025_10_03_154046_create_projekt_allgemeinflaechens_table.php index 5651567..cd918ce 100644 --- a/database/migrations/2025_10_03_154046_create_allgemeinflaechens_table.php +++ b/database/migrations/2025_10_03_154046_create_projekt_allgemeinflaechens_table.php @@ -14,6 +14,8 @@ return new class extends Migration Schema::create('projekt_allgemeinflaechens', function (Blueprint $table) { $table->id(); $table->foreignId('projekte_id')->constrained()->cascadeOnDelete(); + $table->integer('cloned_from_id')->default(0)->nullable(); + $table->boolean('added_manuel')->default(0)->nullable(); $table->string('geschoss')->nullable(); $table->string('raumart')->nullable(); $table->decimal('flaeche', 7, 2)->default(0); diff --git a/database/migrations/2025_10_03_154046_create_projekt_objektes_table.php b/database/migrations/2025_10_03_154046_create_projekt_objektes_table.php index c5fd6eb..9646d3e 100644 --- a/database/migrations/2025_10_03_154046_create_projekt_objektes_table.php +++ b/database/migrations/2025_10_03_154046_create_projekt_objektes_table.php @@ -14,13 +14,13 @@ return new class extends Migration Schema::create('projekt_objektes', function (Blueprint $table) { $table->id(); $table->foreignId('projekte_id')->constrained()->cascadeOnDelete(); - $table->integer('projekte_cloned_from_id')->default(0); + $table->integer('cloned_from_id')->default(0)->nullable(); + $table->boolean('added_manuel')->default(0)->nullable(); $table->integer('orientierung_id')->nullable()->default(0); $table->boolean('nicht_in_orientierung')->default(0); $table->string('top_nummer')->nullable(); $table->string('type')->nullable(); $table->decimal('nutzwert', 5, 2)->default(0)->nullable(); - $table->boolean('added_manuel')->default(0)->nullable(); // 10 Zusatzfelder $table->decimal('a', 5, 2)->default(0); $table->decimal('b', 5, 2)->default(0); diff --git a/database/migrations/2025_10_03_154047_create_projekt_objekte_im_details_table.php b/database/migrations/2025_10_03_154047_create_projekt_objekte_im_details_table.php index 9dbc1d7..293aee2 100644 --- a/database/migrations/2025_10_03_154047_create_projekt_objekte_im_details_table.php +++ b/database/migrations/2025_10_03_154047_create_projekt_objekte_im_details_table.php @@ -14,14 +14,14 @@ return new class extends Migration Schema::create('projekt_objekte_im_details', function (Blueprint $table) { $table->id(); $table->foreignId('projekte_id')->constrained()->cascadeOnDelete(); - $table->integer('projekte_objekte_cloned_from_id')->default(0); + $table->integer('cloned_from_id')->default(0)->nullable(); + $table->boolean('added_manuel')->default(0)->nullable(); $table->foreignId('projekt_objekte_id')->constrained()->cascadeOnDelete(); $table->foreignId('projekt_methode_id'); $table->string('geschoss')->nullable(); $table->string('raumart')->nullable(); $table->decimal('flaeche', 7, 2)->default(0); $table->integer('nutzwert')->default(0)->nullable(); - $table->boolean('added_manuel')->default(0)->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2025_10_06_054823_create_projekt_methodes_table.php b/database/migrations/2025_10_06_054823_create_projekt_methodes_table.php index bd2b3e9..f00fa2b 100644 --- a/database/migrations/2025_10_06_054823_create_projekt_methodes_table.php +++ b/database/migrations/2025_10_06_054823_create_projekt_methodes_table.php @@ -14,6 +14,7 @@ return new class extends Migration Schema::create('projekt_methodes', function (Blueprint $table) { $table->id(); $table->foreignId('projekte_id')->constrained()->cascadeOnDelete(); + $table->integer('cloned_from_id')->default(0)->nullable(); $table->integer('methode_id')->nullable()->default(0); $table->integer('aufstellung_id')->nullable()->default(0); $table->string('raumart')->nullable(); diff --git a/database/migrations/2025_10_06_125215_create_projekt_merkmales_table.php b/database/migrations/2025_10_06_125215_create_projekt_merkmales_table.php index 4cf3e4b..7eb42d6 100644 --- a/database/migrations/2025_10_06_125215_create_projekt_merkmales_table.php +++ b/database/migrations/2025_10_06_125215_create_projekt_merkmales_table.php @@ -14,6 +14,8 @@ return new class extends Migration Schema::create('projekt_merkmales', function (Blueprint $table) { $table->id(); $table->foreignId('projekte_id')->constrained()->cascadeOnDelete(); + $table->integer('cloned_from_id')->default(0)->nullable(); + $table->boolean('added_manuel')->default(0)->nullable(); $table->string('code'); $table->string('name'); $table->timestamps(); diff --git a/database/migrations/2025_10_10_085849_create_projekt_inhaltsverzeichnis_table.php b/database/migrations/2025_10_10_085849_create_projekt_inhaltsverzeichnis_table.php index 99e9d71..f8b93e7 100644 --- a/database/migrations/2025_10_10_085849_create_projekt_inhaltsverzeichnis_table.php +++ b/database/migrations/2025_10_10_085849_create_projekt_inhaltsverzeichnis_table.php @@ -14,6 +14,8 @@ return new class extends Migration Schema::create('projekt_inhaltsverzeichnis', function (Blueprint $table) { $table->id(); $table->foreignId('projekte_id')->constrained()->cascadeOnDelete(); + $table->integer('cloned_from_id')->default(0)->nullable(); + $table->boolean('added_manuel')->default(0)->nullable(); $table->integer('inhaltselement_id')->default(0)->nullable(); $table->integer('inhaltsverzeichnis_id')->default(0)->nullable(); $table->integer('textblock_id')->default(0)->nullable(); diff --git a/database/migrations/2025_10_17_111643_create_projekt_platzhalters_table.php b/database/migrations/2025_10_17_111643_create_projekt_platzhalters_table.php index 72d62ef..7d5e982 100644 --- a/database/migrations/2025_10_17_111643_create_projekt_platzhalters_table.php +++ b/database/migrations/2025_10_17_111643_create_projekt_platzhalters_table.php @@ -14,6 +14,7 @@ return new class extends Migration Schema::create('projekt_platzhalters', function (Blueprint $table) { $table->id(); $table->foreignId('projekte_id')->constrained()->cascadeOnDelete(); + $table->integer('cloned_from_id')->default(0)->nullable(); $table->text('platzhalter')->nullable(); $table->text('platzhaltertext')->nullable(); $table->boolean('controll')->default(0);