user()?->hasRole('sms-admin') ?? false; } protected static ?string $navigationIcon = 'heroicon-o-cube'; public static function form(Form $form): Form { return $form ->schema([ Forms\Components\TextInput::make('name') ->required() ->maxLength(255), Forms\Components\Select::make('unit') ->label('Mengeneinheit') ->native(false) ->searchable() ->live() ->options([ 'grams' => '(Kilo-)Gramm', 'pieces' => 'Stück', 'liter' => 'Liter', ]) ->required(), Forms\Components\TextInput::make('piece_weight') ->label('Ø Stückgewicht (g)') ->numeric() ->suffix('g') ->helperText('Wird automatisch aus Lieferungen errechnet, kann aber auch manuell gesetzt werden.') ->visible(fn (Get $get) => $get('unit') === 'pieces'), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name') ->searchable(), Tables\Columns\TextColumn::make('unit') ->label('Einheit') ->formatStateUsing(fn ($state) => match($state) { 'grams' => '(Kilo-)Gramm', 'pieces' => 'Stück', 'liter' => 'Liter', default => ucfirst($state), }), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]); } public static function getRelations(): array { return [ RelationManagers\StockMovementsRelationManager::class, ]; } public static function getPages(): array { return [ 'index' => Pages\ListSpices::route('/'), 'create' => Pages\CreateSpice::route('/create'), 'view' => Pages\ViewSpice::route('/{record}'), 'edit' => Pages\EditSpice::route('/{record}/edit'), ]; } public static function getPluralLabel(): string { return 'Rohstoffe'; // Setze hier deinen eigenen Pluralbegriff ein } }