Remove recipe name field; use product title internally
Deploy / deploy (push) Successful in 15s

The recipe name input is dropped from the product form — the version
number alone identifies a recipe. The product title is stored as the
internal name to satisfy the NOT NULL constraint. The history table
no longer shows the name column.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Malek TellissiandClaude Sonnet 4.6 committed 2026-09-12 06:00:18 +02:00
1 parent a7e7375edd
commit 269570c7d6
4 files changed
+5 -18

No files matched your search

@@ -54,12 +54,6 @@ class ProductResource extends Resource {
->columnSpanFull(), ->columnSpanFull(),
Forms\Components\Section::make('Rezept') Forms\Components\Section::make('Rezept')
->schema([ ->schema([
TextInput::make('recipe_name')
->label('Name')
->required()
->dehydrated(false)
->afterStateHydrated(fn ($component, $record) =>
$component->state($record?->recipe?->name ?? '')),
Placeholder::make('recipe_version') Placeholder::make('recipe_version')
->label('Version') ->label('Version')
->content(fn ($record) => $record?->recipe ->content(fn ($record) => $record?->recipe
@@ -27,12 +27,11 @@ class CreateProduct extends CreateRecord
]); ]);
} }
$recipeName = $data['recipe_name'] ?? null;
$spices = $data['recipe_spices'] ?? []; $spices = $data['recipe_spices'] ?? [];
if ($recipeName) { if (! empty($spices)) {
$recipe = Recipe::create([ $recipe = Recipe::create([
'name' => $recipeName, 'name' => $data['title'],
'product_id' => $record->id, 'product_id' => $record->id,
'version' => 1, 'version' => 1,
]); ]);
@@ -52,10 +52,9 @@ class EditProduct extends EditRecord
protected function syncRecipe(): void protected function syncRecipe(): void
{ {
$product = $this->record; $product = $this->record;
$name = $this->data['recipe_name'] ?? null;
$spices = $this->data['recipe_spices'] ?? []; $spices = $this->data['recipe_spices'] ?? [];
if (! $name) { if (empty($spices)) {
return; return;
} }
@@ -72,10 +71,7 @@ class EditProduct extends EditRecord
$s->id => (float) $s->pivot->amount_in_percent, $s->id => (float) $s->pivot->amount_in_percent,
])->toArray(); ])->toArray();
$nameChanged = $current->name !== $name; if ($existingPivot == $newPivot) {
$spicesChanged = $existingPivot != $newPivot;
if (! $nameChanged && ! $spicesChanged) {
return; return;
} }
} }
@@ -83,7 +79,7 @@ class EditProduct extends EditRecord
$nextVersion = Recipe::where('product_id', $product->id)->max('version') + 1; $nextVersion = Recipe::where('product_id', $product->id)->max('version') + 1;
$recipe = Recipe::create([ $recipe = Recipe::create([
'name' => $name, 'name' => $product->title,
'product_id' => $product->id, 'product_id' => $product->id,
'version' => $nextVersion, 'version' => $nextVersion,
]); ]);
@@ -60,8 +60,6 @@ class RecipeHistory extends Page implements HasTable
->formatStateUsing(fn ($state) => 'v' . $state) ->formatStateUsing(fn ($state) => 'v' . $state)
->badge() ->badge()
->color(fn (Recipe $recipe) => $recipe->id === $currentRecipeId ? 'success' : 'gray'), ->color(fn (Recipe $recipe) => $recipe->id === $currentRecipeId ? 'success' : 'gray'),
TextColumn::make('name')
->label('Name'),
TextColumn::make('spices_summary') TextColumn::make('spices_summary')
->label('Zutaten') ->label('Zutaten')
->state(fn (Recipe $recipe) => ->state(fn (Recipe $recipe) =>