diff --git a/app/Filament/Resources/Master/Customers/CustomerResource.php b/app/Filament/Resources/Master/Customers/CustomerResource.php new file mode 100644 index 0000000..07edfc8 --- /dev/null +++ b/app/Filament/Resources/Master/Customers/CustomerResource.php @@ -0,0 +1,131 @@ +components([ + TextInput::make('name') + ->label('Nama') + ->placeholder('John Doe') + ->required() + ->maxLength(100) + ->autofocus() + ->autocomplete(false), + + TextInput::make('phone_number') + ->label('Nomor HP') + ->placeholder('08xxxxxxxxxx') + ->required() + ->maxLength(20) + ->autocomplete(false), + + TextInput::make('address') + ->label('Alamat') + ->placeholder('Jl. Raya No. 123, Jakarta Selatan') + ->maxLength(255) + ->autocomplete(false), + ]) + ->columns(1); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('name') + ->label('Nama') + ->searchable() + ->sortable(), + + TextColumn::make('phone_number') + ->label('Nomor HP') + ->searchable() + ->sortable(), + + TextColumn::make('address') + ->label('Alamat') + ->limit(40) + ->toggleable(isToggledHiddenByDefault: true), + + ...TimestampColumns::make(), + ]) + ->filters([ + TrashedFilter::make() + ->native(false), + ]) + ->recordActions([ + EditAction::make() + ->modalWidth(Width::Large), + + DeleteAction::make(), + + ForceDeleteAction::make(), + + RestoreAction::make(), + ]) + ->toolbarActions([ + BulkActionGroup::make([ + ...DefaultBulkActions::make('Pelanggan'), + ]), + ]) + ->emptyStateIcon(Heroicon::UserPlus) + ->emptyStateDescription('Setelah Anda membuat data pertama, maka akan muncul disini.') + ->defaultSort('created_at', 'desc') + ->deferFilters(false); + } + + public static function getPages(): array + { + return [ + 'index' => ManageCustomers::route('/'), + ]; + } + + public static function getRecordRouteBindingEloquentQuery(): Builder + { + return parent::getRecordRouteBindingEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Filament/Resources/Master/Customers/Pages/ManageCustomers.php b/app/Filament/Resources/Master/Customers/Pages/ManageCustomers.php new file mode 100644 index 0000000..ab7bc72 --- /dev/null +++ b/app/Filament/Resources/Master/Customers/Pages/ManageCustomers.php @@ -0,0 +1,31 @@ +label('Tambah') + ->modalHeading('Tambah Pelanggan') + ->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/Models/Customer.php b/app/Models/Customer.php new file mode 100644 index 0000000..dc25f70 --- /dev/null +++ b/app/Models/Customer.php @@ -0,0 +1,14 @@ +id(); + $table->string('name', 100); + $table->string('phone_number', 20); + $table->string('address')->nullable(); + $table->timestamp('created_at')->useCurrent(); + $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('customers'); + } +};