Allow multiple supplier/farmer entries per ingredient in batch origins
Deploy / deploy (push) Successful in 14s
Deploy / deploy (push) Successful in 14s
Each batch origin row now shows a searchable Rohstoff Select so the same ingredient can appear in multiple rows with different suppliers or farmers. Pre-fill from recipe still works (one row per ingredient); user clicks 'Eintrag hinzufügen' to add a second entry for the same ingredient. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
2dffe6f695
commit
400237aa5b
2 files changed
+10
-19
No files matched your search
@@ -132,20 +132,12 @@ class BatchResource extends Resource
|
|||||||
Forms\Components\Repeater::make('origins')
|
Forms\Components\Repeater::make('origins')
|
||||||
->label('')
|
->label('')
|
||||||
->relationship()
|
->relationship()
|
||||||
->afterStateHydrated(function ($component, $record) {
|
|
||||||
// Pre-fill on create only when no origins exist
|
|
||||||
if ($record?->id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// State is set reactively via recipe_id afterStateUpdated
|
|
||||||
})
|
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Hidden::make('spice_id'),
|
Forms\Components\Select::make('spice_id')
|
||||||
Forms\Components\Placeholder::make('spice_name')
|
|
||||||
->label('Rohstoff')
|
->label('Rohstoff')
|
||||||
->content(fn (Get $get): string =>
|
->options(Spice::orderBy('name')->pluck('name', 'id'))
|
||||||
Spice::find($get('spice_id'))?->name ?? '—'
|
->searchable()
|
||||||
),
|
->required(),
|
||||||
|
|
||||||
Forms\Components\Select::make('supplier_id')
|
Forms\Components\Select::make('supplier_id')
|
||||||
->label('Lieferant')
|
->label('Lieferant')
|
||||||
@@ -168,7 +160,7 @@ class BatchResource extends Resource
|
|||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
])
|
])
|
||||||
->columns(2)
|
->columns(2)
|
||||||
->addActionLabel('Rohstoff hinzufügen')
|
->addActionLabel('Eintrag hinzufügen')
|
||||||
->reorderable(false),
|
->reorderable(false),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
|
|||||||
+5
-6
@@ -117,12 +117,11 @@ class BatchesRelationManager extends RelationManager
|
|||||||
])->toArray());
|
])->toArray());
|
||||||
})
|
})
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Hidden::make('spice_id'),
|
Forms\Components\Select::make('spice_id')
|
||||||
Forms\Components\Placeholder::make('spice_name')
|
|
||||||
->label('Rohstoff')
|
->label('Rohstoff')
|
||||||
->content(fn (Get $get): string =>
|
->options(Spice::orderBy('name')->pluck('name', 'id'))
|
||||||
Spice::find($get('spice_id'))?->name ?? '—'
|
->searchable()
|
||||||
),
|
->required(),
|
||||||
|
|
||||||
Forms\Components\Select::make('supplier_id')
|
Forms\Components\Select::make('supplier_id')
|
||||||
->label('Lieferant')
|
->label('Lieferant')
|
||||||
@@ -145,7 +144,7 @@ class BatchesRelationManager extends RelationManager
|
|||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
])
|
])
|
||||||
->columns(2)
|
->columns(2)
|
||||||
->addActionLabel('Rohstoff hinzufügen')
|
->addActionLabel('Eintrag hinzufügen')
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user