- How do I restrict access to the database viewer in Filament?
- Use Filament’s built-in policies or gates to control access. The package integrates seamlessly with Filament’s authorization system, so you can restrict the DB View plugin to specific roles or users via `canAccessPanel()` or custom gates in your Filament panel configuration. For example, you might gate access to admin-only users or roles with database inspection permissions.
- Does this package support non-Eloquent tables (e.g., raw MySQL tables or PostgreSQL schemas)?
- No, this package is strictly Eloquent-centric. It only exposes tables backed by Laravel models. If you need to inspect raw database tables or views, consider using Laravel’s `Schema::getConnection()` to query them directly in your application logic, or explore alternatives like Laravel Debugbar or custom-built solutions for raw SQL access.
- Will this work with Laravel 10.x or Filament v3.x?
- No, this package requires **Laravel 11/12/13** and **Filament v4/5**. The package leverages Filament’s modern UI components and Laravel’s updated features, so older versions are not supported. If you’re on Laravel 10 or Filament v3, you’ll need to upgrade or seek alternatives like custom-built tools or older packages.
- Can I use the Query Runner to execute non-SELECT queries (e.g., SHOW TABLES, DESCRIBE)?
- No, the Query Runner is **read-only and SELECT-only** by design. It intentionally blocks destructive or schema-altering queries to prevent accidental data changes. For schema inspection, use the built-in **table structure view** (columns, indexes, foreign keys) or run `DESCRIBE` or `SHOW TABLES` queries in a separate tool like Laravel Tinker or Adminer.
- How do I handle large tables (e.g., 100K+ rows) in the Database Browser?
- The Database Browser uses Filament’s native table component, which includes **pagination, lazy loading, and column filtering** to improve performance. For very large tables, ensure your database indexes are optimized and consider adding custom query scopes or filters in your Eloquent models. If performance is still an issue, you may need to pre-load data or use database views.
- Is query history logged for auditing purposes? How can I integrate it with Laravel’s logging?
- Yes, the package stores query history per-user in the `dbview_query_history` table by default. To integrate with Laravel’s logging, you can extend the `QueryHistory` model or use Laravel’s logging channels to log queries from the `retrieved` event. For compliance-heavy environments, consider pairing this with a dedicated audit logging package like `spatie/laravel-audit-log`.
- Do I need to run migrations if I don’t use the Query Runner’s history or saved queries?
- Yes, the migrations are required by default, but you can disable the history and saved queries features in the config file (`config/filament-dbview.php`). Set `enable_query_history` and `enable_saved_queries` to `false` to skip these tables entirely. This reduces database overhead if you only need the Database Browser.
- Are there any alternatives to this package for Laravel + Filament?
- If you need a read-only database viewer, alternatives include **Laravel Debugbar** (for quick SQL inspection) or **Adminer** (self-hosted, but not Filament-integrated). For Filament-specific tools, consider **Filament Tables** with custom queries or **Nova’s built-in tools** (if using Nova). However, this package is uniquely optimized for Filament’s UI and Laravel’s Eloquent ecosystem.
- How do I customize the Database Browser’s columns or add filters?
- You can customize the Database Browser by overriding the table columns in your Filament panel’s configuration. Use Filament’s `Table` component modifiers to hide/show columns, add custom filters, or modify the query. For example, extend the `DbviewPlugin` class or use Filament’s `modifyTable()` method to inject your logic. The package leverages Filament’s plugin system for extensibility.
- Will this package slow down my production database if used frequently?
- The package is designed to be efficient, but heavy usage of `EXPLAIN` or large queries could impact performance. Mitigate this by **rate-limiting access** (e.g., restrict to trusted roles) or **caching frequent queries**. Monitor your database load and consider disabling `EXPLAIN` in production if it’s not critical. The Query Runner also supports saved queries to reduce redundant executions.