Add lot_prefix to products; compose LOT number from prefix + date suffix
Deploy / deploy (push) Successful in 14s

Products now have a configurable lot_prefix (e.g. "112"). In the batch form
the prefix is shown read-only next to the suffix input (JJMMTT), and the full
lot_number (e.g. "112-260912") is composed automatically and stored.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Malek TellissiandClaude Sonnet 4.6 committed 2026-09-12 20:35:37 +02:00
1 parent e9734c2590
commit 5c034ec895
6 files changed
+87 -12

No files matched your search

@@ -24,11 +24,31 @@ class BatchesRelationManager extends RelationManager
public function form(Form $form): Form
{
return $form->schema([
Forms\Components\TextInput::make('lot_number')
Forms\Components\TextInput::make('lot_suffix')
->label('LOT-Nummer')
->prefix(fn ($livewire): ?string => $livewire->getOwnerRecord()->lot_prefix
? $livewire->getOwnerRecord()->lot_prefix . ' -'
: null
)
->placeholder('JJMMTT')
->maxLength(50)
->required()
->unique(ignoreRecord: true)
->maxLength(255),
->dehydrated(false)
->live()
->afterStateHydrated(function ($component, $record) {
if (! $record?->lot_number) return;
$pos = strrpos($record->lot_number, '-');
$component->state($pos !== false
? substr($record->lot_number, $pos + 1)
: $record->lot_number
);
})
->afterStateUpdated(function ($state, $set, $livewire) {
$prefix = $livewire->getOwnerRecord()->lot_prefix;
$set('lot_number', $prefix ? "{$prefix}-{$state}" : $state);
}),
Forms\Components\Hidden::make('lot_number'),
Forms\Components\Select::make('size_id')
->label('Variante (Verpackung)')