diff --git a/app/Filament/Resources/Master/Units/Pages/ManageUnits.php b/app/Filament/Resources/Master/Units/Pages/ManageUnits.php new file mode 100644 index 0000000..99f2160 --- /dev/null +++ b/app/Filament/Resources/Master/Units/Pages/ManageUnits.php @@ -0,0 +1,31 @@ +label('Tambah') + ->modalHeading('Tambah Satuan') + ->modalSubmitActionLabel('Simpan') + ->modalCancelActionLabel('Batal') + ->extraModalFooterActions(fn (CreateAction $action): array => [ + $action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) + ->label('Simpan dan Tambah Lagi'), + ]) + ->modalWidth(Width::Large), + ]; + } +} diff --git a/app/Filament/Resources/Master/Units/UnitResource.php b/app/Filament/Resources/Master/Units/UnitResource.php new file mode 100644 index 0000000..c773817 --- /dev/null +++ b/app/Filament/Resources/Master/Units/UnitResource.php @@ -0,0 +1,120 @@ +components([ + TextInput::make('name') + ->label('Nama') + ->placeholder('Kilogram') + ->required() + ->maxLength(50) + ->autofocus() + ->autocomplete(false), + + TextInput::make('alias') + ->label('Alias') + ->placeholder('Kg') + ->required() + ->maxLength(20) + ->autocomplete(false), + ]) + ->columns(1); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('name') + ->label('Nama') + ->searchable() + ->sortable(), + + TextColumn::make('alias') + ->label('Alias') + ->searchable() + ->sortable(), + + ...TimestampColumns::make(), + ]) + ->filters([ + TrashedFilter::make() + ->native(false), + ]) + ->recordActions([ + EditAction::make() + ->modalWidth(Width::Large), + + DeleteAction::make(), + + ForceDeleteAction::make(), + + RestoreAction::make(), + ]) + ->toolbarActions([ + BulkActionGroup::make([ + ...DefaultBulkActions::make('Satuan'), + ]), + ]) + ->emptyStateIcon(Heroicon::Scale) + ->emptyStateDescription('Setelah Anda membuat data pertama, maka akan muncul disini.') + ->defaultSort('created_at', 'desc') + ->deferFilters(false); + } + + public static function getPages(): array + { + return [ + 'index' => ManageUnits::route('/'), + ]; + } + + public static function getRecordRouteBindingEloquentQuery(): Builder + { + return parent::getRecordRouteBindingEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Models/Unit.php b/app/Models/Unit.php new file mode 100644 index 0000000..b357b44 --- /dev/null +++ b/app/Models/Unit.php @@ -0,0 +1,13 @@ +id(); + $table->string('name', 50); + $table->string('alias', 20); + $table->timestamp('created_at')->useCurrent(); + $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('units'); + } +};