Features Added - 2026-02-21
All requested features have been successfully implemented in the Filament Database package.
✅ Feature 1: Export (CSV/JSON/SQL)
Files Created:
src/Actions/ExportTable.php- Reusable export helper class
Files Modified:
src/Pages/DatabaseManager.php- Added export action to table header
Implementation:
- Export action available in table header actions (always allowed, even in read-only mode)
- Modal form with format selection (CSV, JSON, SQL INSERT)
- Option to export current page or all rows
- Streams file as download response
- CSV: standard format with headers
- JSON: array of objects with pretty printing
- SQL: INSERT INTO statements with proper escaping
Usage: Click "Export" button in table header → Select format and scope → Download
✅ Feature 2: Import (CSV)
Files Created:
src/Actions/ImportTable.php- Reusable import helper class
Files Modified:
src/Pages/DatabaseManager.php- Added import action to table header
Implementation:
- Import action available in table header (blocked in read-only mode)
- File upload field for CSV files
- Auto-matches CSV headers to table columns (case-insensitive)
- Inserts rows via Query Builder
- Shows success/error count via Notification
- Error messages for failed rows included in notification
- Keeps last 20 queries in history
Usage: Click "Import" button → Upload CSV file → Auto-mapping happens → Confirm import
✅ Feature 3: Table Search in Dropdown
Files Modified:
src/Pages/DatabaseManager.php- Added$tableSearchpropertyresources/views/pages/database-manager.blade.php- Added search input with live filtering
Implementation:
- Search input above table dropdown
- Live filtering with 300ms debounce
- Case-insensitive search using
stripos() - Shows "No tables match" message when no results
Usage: Type in the search box above the table dropdown to filter tables
✅ Feature 4: Row Count in Table Dropdown
Files Modified:
src/Pages/DatabaseManager.php- UpdatedgetFilteredTables()methodresources/views/pages/database-manager.blade.php- Display row counts in dropdown
Implementation:
- MySQL: Uses
information_schema.TABLESfor fast cached counts - SQLite/PostgreSQL: Individual COUNT queries with static caching
- Displays as "table_name (1,234)" in dropdown
- Graceful fallback if count query fails
Usage: Row counts automatically show in parentheses next to table names
✅ Feature 5: Column Editing
Files Modified:
src/Concerns/InteractsWithDatabase.php- AddedrenameColumn()andmodifyColumn()methodssrc/Pages/DatabaseManager.php- AddedgetEditColumnAction()andmapDbTypeToSchemaType()methodsresources/views/pages/partials/structure.blade.php- Added Edit button per column
Implementation:
- Edit button for each column in Structure tab
- Modal form with fields: name, type, nullable, default
- Renames column if name changed
- Modifies column type and properties
- Logs changes when audit logging enabled
- Includes intelligent type mapping from DB types to Laravel schema types
Usage: Go to Structure tab → Click "Edit" next to any column → Modify properties → Save
✅ Feature 6: SQL History
Files Modified:
src/Pages/DatabaseManager.php- Added$sqlHistoryproperty andloadHistoryQuery()method- Updated
executeSql()to track query history resources/views/pages/partials/sql.blade.php- Display clickable history items
Implementation:
- Tracks last 20 executed queries
- Stores: query, execution time, row count, duration
- Clickable history items populate the SQL textarea
- Shows execution time in milliseconds
- Records failed queries with 'error' duration
- Scrollable history panel with hover effects
Usage: Execute SQL queries → History appears below → Click any history item to reload that query
✅ Feature 7: NULL vs Empty String Distinction
Files Modified:
src/Concerns/BuildsFormFields.php- Added NULL checkbox for nullable string/text fieldssrc/Pages/DatabaseManager.php- AddedprocessNullCheckboxes()helper method- Updated insert and edit actions to process NULL checkboxes
Implementation:
- "Set NULL" checkbox appears for nullable string/text fields
- Checking the box explicitly sets the value to NULL
- Live update clears the field when checkbox is checked
- Helper method processes
__nullsuffixed fields - Preserves explicit NULL values during insert (not filtered out as empty)
Usage: When editing/inserting rows with nullable text fields, check "Set [field] to NULL" checkbox to set NULL instead of empty string
✅ Feature 8: Copy Cell Value
Files Modified:
src/Pages/DatabaseManager.php- Added->copyable()to all TextColumn instances
Implementation:
- Uses Filament's built-in
copyable()method - Copy icon appears on hover for each table cell
- "Copied!" toast message for 1.5 seconds
- Works for all column values
Usage: Hover over any table cell → Click copy icon → Value copied to clipboard
Technical Notes
Code Quality
- ✅ All new PHP files include
declare(strict_types=1)as requested - ✅ All existing tests pass (111 tests, 195 assertions)
- ✅ No syntax errors in any files
- ✅ Used Filament native components throughout
- ✅ Follows existing code style and patterns
- ✅ Proper error handling with try-catch blocks
- ✅ Audit logging integrated where appropriate
CSS & Styling
- Package views use scoped CSS classes (fdb-*)
- CSS variables (var(--gray-*)) for dark mode compatibility
- No Tailwind classes used (as they don't compile for packages)
- Inline styles used sparingly for dynamic elements
Performance Considerations
- Row counts cached using static variables
- MySQL uses information_schema for fast counts
- Export uses streaming to handle large datasets
- SQL history limited to 20 items to prevent memory issues
Security
- Export always uses streaming (memory efficient)
- Import validates file types
- SQL injection protection via parameter binding
- Destructive operations respect read-only mode
- Import blocked in read-only mode
- Export allowed in read-only mode
Browser Compatibility
- All features use standard web APIs
- Copy functionality uses Filament's built-in method
- No custom clipboard API usage required
Testing Recommendations
While all existing tests pass, consider adding tests for:
- Export functionality (CSV/JSON/SQL format validation)
- Import with various CSV formats
- NULL checkbox behavior
- SQL history tracking
- Column editing operations
- Row count caching
Known Limitations
- Import: Currently auto-maps columns by name only. Manual mapping UI would require more complex wizard implementation.
- Column Editing: Renaming columns may fail on some databases if there are dependencies (foreign keys, indexes)
- Row Counts: May be slow for very large tables on SQLite/PostgreSQL (uses COUNT queries)
- SQL History: Stored in component state, not persisted across sessions
Future Enhancements
Potential improvements for future versions:
- Manual column mapping UI for imports
- Export with filters/search applied
- Import preview with validation
- Persistent SQL history (session/database storage)
- Batch column operations
- More export formats (XML, Excel)