From 064fceaca0e2fe3e5f1f89a9c8630c4b0244d6c6 Mon Sep 17 00:00:00 2001 From: salam Date: Mon, 6 Oct 2025 09:40:32 +0200 Subject: [PATCH] Raum Methode wip --- .../ProjektMethodesRelationManager.php | 13 ++++-- app/Models/ProjektMethode.php | 4 +- bootstrap/cache/routes-v7.php | 42 +++++++++---------- ...6_054823_create_projekt_methodes_table.php | 2 +- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/app/Filament/Resources/Projektes/RelationManagers/ProjektMethodesRelationManager.php b/app/Filament/Resources/Projektes/RelationManagers/ProjektMethodesRelationManager.php index 930b210..8508df2 100644 --- a/app/Filament/Resources/Projektes/RelationManagers/ProjektMethodesRelationManager.php +++ b/app/Filament/Resources/Projektes/RelationManagers/ProjektMethodesRelationManager.php @@ -4,9 +4,11 @@ namespace App\Filament\Resources\Projektes\RelationManagers; use App\Actions\CreateProjektMethoden; use App\Models\Methode; +use App\Models\ProjektMethode; use Filament\Actions\Action; use Filament\Actions\BulkAction; use Filament\Actions\BulkActionGroup; +use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Resources\RelationManagers\RelationManager; use Filament\Tables\Columns\SelectColumn; @@ -34,7 +36,9 @@ class ProjektMethodesRelationManager extends RelationManager ->recordTitleAttribute('raumart') ->columns([ SelectColumn::make('methode_id') - ->options(Methode::query()->pluck('name', 'id')), + ->selectablePlaceholder(true) + ->optionsRelationship('methode', 'name') + ->preloadOptions(), TextColumn::make('raumart') ->searchable(), TextInputColumn::make('faktor') @@ -82,9 +86,10 @@ class ProjektMethodesRelationManager extends RelationManager ->color('primary') ->label('Methode zuweisen') ->schema([ - TextInput::make('faktor') + Select::make('methode_id') + ->label('Methode') ->prefixIcon('phosphor-calculator') - ->numeric() + ->options(Methode::pluck('name', 'id')) ->required(), ]) ->icon('phosphor-calculator') @@ -92,7 +97,7 @@ class ProjektMethodesRelationManager extends RelationManager foreach ($records as $record) { ProjektMethode::where('id', '=', $record->id) ->update( - ['faktor' => $data['faktor']] + ['methode_id' => $data['methode_id']] ); } }), diff --git a/app/Models/ProjektMethode.php b/app/Models/ProjektMethode.php index 7faed4a..f1d2d02 100644 --- a/app/Models/ProjektMethode.php +++ b/app/Models/ProjektMethode.php @@ -14,8 +14,8 @@ class ProjektMethode extends Model 'flaeche', ]; - public function methodes() + public function methode() { - return $this->hasMany(Methode::class); + return $this->hasOne(Methode::class, 'id', 'methode_id'); } } diff --git a/bootstrap/cache/routes-v7.php b/bootstrap/cache/routes-v7.php index af103c0..62e274a 100644 --- a/bootstrap/cache/routes-v7.php +++ b/bootstrap/cache/routes-v7.php @@ -511,7 +511,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::NzP4VI5PeVTSNa8b', + '_route' => 'generated::3ZvPcx4wzGcazHjY', ), 1 => NULL, 2 => @@ -531,7 +531,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::pt0LAwcB1sGBW4Oo', + '_route' => 'generated::lOdfu1T7yU5apto8', ), 1 => NULL, 2 => @@ -589,7 +589,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::AOiPiqGBrqXDsS0D', + '_route' => 'generated::LPhTcSOFWcUu5PaT', ), 1 => NULL, 2 => @@ -609,7 +609,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::P6HogTayo2iWezmY', + '_route' => 'generated::cvHOt1jrrRN3xfiY', ), 1 => NULL, 2 => @@ -629,7 +629,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::MTlI6TBwxyNMQmB6', + '_route' => 'generated::bonAslfzukOeepe8', ), 1 => NULL, 2 => @@ -649,7 +649,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::hTSXazyycB1PbjMf', + '_route' => 'generated::6FKILztAKPwOYAG8', ), 1 => NULL, 2 => @@ -669,7 +669,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::72CUCq6E4ZsFkqBN', + '_route' => 'generated::ztTjaopi6XfNllCu', ), 1 => NULL, 2 => @@ -2595,7 +2595,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::NzP4VI5PeVTSNa8b' => + 'generated::3ZvPcx4wzGcazHjY' => array ( 'methods' => array ( @@ -2607,7 +2607,7 @@ app('router')->setCompiledRoutes( array ( 'uses' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@returnJavaScriptAsFile', 'controller' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@returnJavaScriptAsFile', - 'as' => 'generated::NzP4VI5PeVTSNa8b', + 'as' => 'generated::3ZvPcx4wzGcazHjY', ), 'fallback' => false, 'defaults' => @@ -2623,7 +2623,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::pt0LAwcB1sGBW4Oo' => + 'generated::lOdfu1T7yU5apto8' => array ( 'methods' => array ( @@ -2635,7 +2635,7 @@ app('router')->setCompiledRoutes( array ( 'uses' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@maps', 'controller' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@maps', - 'as' => 'generated::pt0LAwcB1sGBW4Oo', + 'as' => 'generated::lOdfu1T7yU5apto8', ), 'fallback' => false, 'defaults' => @@ -2737,7 +2737,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::AOiPiqGBrqXDsS0D' => + 'generated::LPhTcSOFWcUu5PaT' => array ( 'methods' => array ( @@ -2766,7 +2766,7 @@ app('router')->setCompiledRoutes( \'exception\' => $exception, ]), status: $exception ? 500 : 200); }";s:5:"scope";s:54:"Illuminate\\Foundation\\Configuration\\ApplicationBuilder";s:4:"this";N;s:4:"self";s:32:"0000000000000f2c0000000000000000";}}', - 'as' => 'generated::AOiPiqGBrqXDsS0D', + 'as' => 'generated::LPhTcSOFWcUu5PaT', ), 'fallback' => false, 'defaults' => @@ -2782,7 +2782,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::P6HogTayo2iWezmY' => + 'generated::cvHOt1jrrRN3xfiY' => array ( 'methods' => array ( @@ -2804,7 +2804,7 @@ app('router')->setCompiledRoutes( 'where' => array ( ), - 'as' => 'generated::P6HogTayo2iWezmY', + 'as' => 'generated::cvHOt1jrrRN3xfiY', ), 'fallback' => false, 'defaults' => @@ -2820,7 +2820,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::MTlI6TBwxyNMQmB6' => + 'generated::bonAslfzukOeepe8' => array ( 'methods' => array ( @@ -2842,7 +2842,7 @@ app('router')->setCompiledRoutes( 'where' => array ( ), - 'as' => 'generated::MTlI6TBwxyNMQmB6', + 'as' => 'generated::bonAslfzukOeepe8', ), 'fallback' => false, 'defaults' => @@ -2858,7 +2858,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::hTSXazyycB1PbjMf' => + 'generated::6FKILztAKPwOYAG8' => array ( 'methods' => array ( @@ -2880,7 +2880,7 @@ app('router')->setCompiledRoutes( 'where' => array ( ), - 'as' => 'generated::hTSXazyycB1PbjMf', + 'as' => 'generated::6FKILztAKPwOYAG8', ), 'fallback' => false, 'defaults' => @@ -2896,7 +2896,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::72CUCq6E4ZsFkqBN' => + 'generated::ztTjaopi6XfNllCu' => array ( 'methods' => array ( @@ -2918,7 +2918,7 @@ app('router')->setCompiledRoutes( 'where' => array ( ), - 'as' => 'generated::72CUCq6E4ZsFkqBN', + 'as' => 'generated::ztTjaopi6XfNllCu', ), 'fallback' => false, 'defaults' => 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 2ed3cc6..ca0f29e 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,7 +14,7 @@ return new class extends Migration Schema::create('projekt_methodes', function (Blueprint $table) { $table->id(); $table->foreignId('projekte_id')->constrained()->cascadeOnDelete(); - $table->integer('methode_id')->default(0); + $table->integer('methode_id')->nullable()->default(0); $table->string('geschoss')->nullable(); $table->string('raumart')->nullable(); $table->decimal('faktor', 5, 2)->default(0);