feat(feat): add price and adjust logic
This commit is contained in:
parent
f165af78be
commit
bd86ff2159
@ -19,6 +19,7 @@
|
|||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Support\Enums\Width;
|
use Filament\Support\Enums\Width;
|
||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Support\RawJs;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Filters\SelectFilter;
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
use Filament\Tables\Filters\TrashedFilter;
|
use Filament\Tables\Filters\TrashedFilter;
|
||||||
@ -69,6 +70,17 @@ public static function form(Schema $schema): Schema
|
|||||||
->required()
|
->required()
|
||||||
->native(false)
|
->native(false)
|
||||||
->default(FeedStatus::AVAILABLE),
|
->default(FeedStatus::AVAILABLE),
|
||||||
|
|
||||||
|
TextInput::make('price')
|
||||||
|
->label('Harga')
|
||||||
|
->placeholder('1,000,000')
|
||||||
|
->autocomplete(false)
|
||||||
|
->autofocus()
|
||||||
|
->required()
|
||||||
|
->mask(RawJs::make('$money($input)'))
|
||||||
|
->prefix('Rp')
|
||||||
|
->helperText('Harga per satuan yang dipilih.')
|
||||||
|
->dehydrateStateUsing(fn ($state) => str_replace(',', '', $state)),
|
||||||
])
|
])
|
||||||
->columns(1);
|
->columns(1);
|
||||||
}
|
}
|
||||||
@ -88,6 +100,10 @@ public static function table(Table $table): Table
|
|||||||
->suffix(fn (Feed $record) => ' '.$record->unit->alias)
|
->suffix(fn (Feed $record) => ' '.$record->unit->alias)
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('price')
|
||||||
|
->label('Harga')
|
||||||
|
->money('IDR', decimalPlaces: 0),
|
||||||
|
|
||||||
TextColumn::make('status')
|
TextColumn::make('status')
|
||||||
->label('Status')
|
->label('Status')
|
||||||
->badge()
|
->badge()
|
||||||
|
|||||||
@ -18,6 +18,7 @@ protected function casts(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'stock' => 'decimal:2',
|
'stock' => 'decimal:2',
|
||||||
|
'price' => 'integer',
|
||||||
'status' => FeedStatus::class,
|
'status' => FeedStatus::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -27,6 +28,11 @@ public function unit(): BelongsTo
|
|||||||
return $this->belongsTo(Unit::class);
|
return $this->belongsTo(Unit::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function purchaseItems(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(FeedPurchaseItem::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function purchases(): HasMany
|
public function purchases(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(FeedPurchase::class);
|
return $this->hasMany(FeedPurchase::class);
|
||||||
|
|||||||
@ -17,6 +17,7 @@ public function up(): void
|
|||||||
$table->string('name', 50);
|
$table->string('name', 50);
|
||||||
$table->foreignId('unit_id')->constrained()->cascadeOnDelete();
|
$table->foreignId('unit_id')->constrained()->cascadeOnDelete();
|
||||||
$table->decimal('stock', 15, 2)->default(0);
|
$table->decimal('stock', 15, 2)->default(0);
|
||||||
|
$table->unsignedInteger('price');
|
||||||
$table->enum('status', FeedStatus::cases())->default(FeedStatus::AVAILABLE->value)->comment(FeedStatus::comment());
|
$table->enum('status', FeedStatus::cases())->default(FeedStatus::AVAILABLE->value)->comment(FeedStatus::comment());
|
||||||
$table->timestamp('created_at')->useCurrent();
|
$table->timestamp('created_at')->useCurrent();
|
||||||
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
|
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user