refactor: Update Feed model and resource to use integer for stock and adjust price formatting
This commit is contained in:
parent
244a548a4c
commit
71ea216b96
@ -19,7 +19,6 @@
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Support\RawJs;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tables\Table;
|
||||
@ -65,11 +64,11 @@ public static function form(Schema $schema): Schema
|
||||
|
||||
TextInput::make('price')
|
||||
->label('Harga')
|
||||
->placeholder('1,000,000')
|
||||
->placeholder('1.000.000')
|
||||
->autocomplete(false)
|
||||
->autofocus()
|
||||
->required()
|
||||
->mask(RawJs::make('$money($input)'))
|
||||
->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0)
|
||||
->prefix('Rp')
|
||||
->helperText('Harga per satuan yang dipilih.')
|
||||
->dehydrateStateUsing(fn ($state) => str_replace(',', '', $state)),
|
||||
@ -101,7 +100,7 @@ public static function table(Table $table): Table
|
||||
|
||||
TextColumn::make('stock')
|
||||
->label('Stok')
|
||||
->numeric(decimalPlaces: 2)
|
||||
->numeric(decimalPlaces: 0)
|
||||
->suffix(fn (Feed $record) => ' '.$record->unit->alias)
|
||||
->sortable(),
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ class Feed extends Model implements HasMedia
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'stock' => 'decimal:2',
|
||||
'stock' => 'integer',
|
||||
'price' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ public function up(): void
|
||||
$table->id();
|
||||
$table->string('name', 50);
|
||||
$table->foreignId('unit_id')->constrained()->cascadeOnDelete();
|
||||
$table->decimal('stock', 15, 2)->default(0);
|
||||
$table->unsignedInteger('stock')->default(0);
|
||||
$table->unsignedInteger('price');
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user