- What Laravel/Filament versions does this package support?
- This package is designed for Filament v3+ and Laravel 9+. Always check the package’s `composer.json` for the latest supported versions, as Filament updates may introduce breaking changes. If you’re using Filament v4, verify compatibility, as some features like styling may align better with newer versions.
- How do I install and set up the date range picker in my Filament table?
- Run `composer require malzariey/filament-daterangepicker-filter` to install. Then, add the filter to your Filament table using `DateRangeFilter::make('column_name')` in your table’s `getFilters()` method. For fields, use `DateRangePicker::make('column_name')` in forms. Publish translations with `php artisan vendor:publish --tag=filament-daterangepicker-filter-translations` if needed.
- Can I customize the date format or picker type (day/month/year)?
- Yes, you can switch between day, month, or year pickers using methods like `monthPicker()` or `yearPicker()`. Customize the format with `format('d/m/Y')` or similar. For example, `->monthPicker()->format('F Y')` displays months as 'January 2023'. Time selection is also optional via the picker’s native settings.
- Does this package work with Filament’s query builder for complex date logic?
- The package generates SQL queries for date ranges (e.g., `BETWEEN`, `>=`, `<=`), but it relies on Filament’s built-in query builder. For advanced logic like time zones or custom fiscal calendars, you’ll need to extend the query builder manually or use Filament’s `modifyQueryUsing` method to override the generated SQL.
- How do I handle localization (e.g., RTL languages or custom date formats)?
- The package supports localization via Day.js locales. Publish translations with the `vendor:publish` command and configure your app’s locale settings. For RTL languages, ensure your Filament theme supports RTL and override CSS if needed. Custom formats like `DD/MM/YYYY` can be set using the `format()` method.
- Will this conflict with other JavaScript date libraries (e.g., Flatpickr, jQuery UI)?
- Potential conflicts may arise if multiple libraries target the same DOM elements or use overlapping CSS/JS namespaces. Isolate the package by loading `daterangepicker.js` via a CDN or bundling it separately in your Vite/Laravel Mix setup. Avoid jQuery conflicts by ensuring the library is loaded after jQuery if required.
- Can I use this package in non-Filament Laravel apps (e.g., Livewire or Inertia)?
- No, this package is tightly coupled to Filament’s architecture and won’t work outside of it. For Livewire or Inertia, consider standalone libraries like `daterangepicker.js` or Filament’s native `DateFilter`. If you’re migrating from Filament, you’ll need to rebuild the UI logic manually.
- Are there any performance concerns with large datasets (e.g., 10K+ records)?
- The package itself adds minimal overhead, but performance depends on Filament’s query builder and your database. Test with large datasets to ensure the generated SQL (e.g., `BETWEEN` clauses) doesn’t cause timeouts. Optimize with database indexes on filtered columns or paginate results in Filament’s table settings.
- How do I test edge cases like invalid date ranges or null values?
- Manually test by submitting empty ranges or null values in the picker. The package should handle basic validation, but add server-side checks in your Filament filter’s `apply()` method if needed. For automated testing, use PHPUnit to mock the filter and verify query outputs. Check the package’s tests (if any) for examples.
- What alternatives exist for date filtering in Filament?
- Filament’s native `DateFilter` offers basic date range functionality but lacks presets and advanced picker options. For more control, consider `spatie/laravel-filament-resources` or standalone libraries like `flatpickr` integrated into custom Filament fields. Evaluate based on your need for presets, UI consistency, or backend logic.