Rohstoffe: inline creation in Lieferung form, hide nav entry, remove quantity column
Deploy / deploy (push) Successful in 17s
Deploy / deploy (push) Successful in 17s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
a85afbc93a
commit
22fb5ed09d
2 files changed
+24
-12
No files matched your search
@@ -21,6 +21,7 @@ class SpiceResource extends Resource
|
|||||||
protected static ?string $slug = 'rohstoffe';
|
protected static ?string $slug = 'rohstoffe';
|
||||||
protected static ?string $navigationGroup = 'Lager';
|
protected static ?string $navigationGroup = 'Lager';
|
||||||
|
|
||||||
|
protected static bool $shouldRegisterNavigation = false;
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-cube';
|
protected static ?string $navigationIcon = 'heroicon-o-cube';
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
@@ -49,17 +50,13 @@ class SpiceResource extends Resource
|
|||||||
->columns([
|
->columns([
|
||||||
Tables\Columns\TextColumn::make('name')
|
Tables\Columns\TextColumn::make('name')
|
||||||
->searchable(),
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('quantity')->label('Menge lagernd')
|
Tables\Columns\TextColumn::make('unit')
|
||||||
->formatStateUsing(function (Spice $record) {
|
->label('Einheit')
|
||||||
if ($record->unit == 'grams') {
|
->formatStateUsing(fn ($state) => match($state) {
|
||||||
return ($record->quantity >= 1000) ? round($record->quantity / 1000, 2) . 'kg' : $record->quantity . 'g';
|
'grams' => '(Kilo-)Gramm',
|
||||||
}elseif($record->unit == 'pieces'){
|
'pieces' => 'Stück',
|
||||||
return $record->quantity . ' Stück';
|
'liter' => 'Liter',
|
||||||
}elseif($record->unit == 'liter'){
|
default => ucfirst($state),
|
||||||
return $record->quantity . ' Liter';
|
|
||||||
}else{
|
|
||||||
return $record->quantity . ' ' . ucfirst($record->unit);
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
|
|||||||
@@ -40,7 +40,22 @@ class SpiceSupplierResource extends Resource
|
|||||||
->relationship('spice', 'name')
|
->relationship('spice', 'name')
|
||||||
->required()
|
->required()
|
||||||
->preload()
|
->preload()
|
||||||
->searchable(),
|
->searchable()
|
||||||
|
->createOptionForm([
|
||||||
|
TextInput::make('name')->label('Name')->required()->maxLength(255),
|
||||||
|
Forms\Components\Select::make('unit')
|
||||||
|
->label('Mengeneinheit')
|
||||||
|
->native(false)
|
||||||
|
->options([
|
||||||
|
'grams' => '(Kilo-)Gramm',
|
||||||
|
'pieces' => 'Stück',
|
||||||
|
'liter' => 'Liter',
|
||||||
|
])
|
||||||
|
->required(),
|
||||||
|
])
|
||||||
|
->createOptionUsing(function (array $data) {
|
||||||
|
return \App\Models\Spice::create($data)->id;
|
||||||
|
}),
|
||||||
Select::make('supplier_id')
|
Select::make('supplier_id')
|
||||||
->label('Lieferant')
|
->label('Lieferant')
|
||||||
->relationship('supplier', 'name')
|
->relationship('supplier', 'name')
|
||||||
|
|||||||
Reference in new issue
Block a user