- How do I add a star rating field to a Filament form or table?
- Use the `RatingStar` field in your Filament resource. For forms, add `RatingStar::make('Rating')` to your form fields. For tables, include it as a column with `RatingStar::make('Rating')`. The package provides a fluent API for customization like `maxStars(5)` or `default(3)`.
- Does this package work with Filament v3?
- Yes, this package is designed for Filament v3+. If your project uses an older version, you’ll need to upgrade Filament first. Check the package’s `composer.json` for exact Filament version requirements, which are typically listed under `require`.
- Can I customize the appearance of the star rating widget?
- Absolutely. The package supports Tailwind CSS classes for styling, allowing you to match your admin panel’s design system. You can override default styles via the `classes()` method or by publishing the package’s assets. Half-stars and custom icons are also configurable.
- What Laravel versions does this package support?
- The package is built for modern Laravel applications, typically targeting Laravel 9.x or 10.x. Always verify the `composer.json` of the package for the exact Laravel version range, as this can vary slightly between releases. PHP 8.1+ is usually required.
- How do I store and retrieve star ratings in my database?
- The package handles the UI layer only—you’ll need to define an Eloquent attribute (e.g., `rating`) in your model to store the numeric value. Use Laravel’s built-in validation rules like `integer` or `between:1,5` to ensure data integrity. The widget syncs with this attribute automatically.
- Will this package conflict with other Filament widgets or plugins?
- The package is designed to integrate seamlessly with Filament’s component architecture, but conflicts can arise if other plugins modify the same UI elements. Test the widget in isolation first, and use Filament’s `after` or `before` hooks if custom ordering is needed. Check for CSS class overlaps.
- Can I use this for high-traffic admin panels with thousands of ratings?
- Yes, the package is lightweight and optimized for performance. However, ensure your database and backend logic (e.g., caching aggregated ratings) can handle the load. Test under realistic conditions, especially if ratings are frequently updated or displayed in tables with many rows.
- Is there built-in support for half-stars or fractional ratings?
- Yes, the package supports half-stars out of the box. By default, it rounds to the nearest half-star, but you can adjust precision via configuration or custom CSS. For fractional ratings (e.g., 3.5), ensure your database column uses a `decimal` type instead of an integer.
- How do I handle validation for star ratings in Filament forms?
- Use Laravel’s validation rules in your Filament form’s `rules()` method. For example, `rules(['rating' => 'required|integer|between:1,5'])` ensures ratings are within a valid range. The package doesn’t enforce validation—it relies on your existing Laravel validation logic.
- Are there alternatives to this package for Filament star ratings?
- If you’re looking for alternatives, consider `filament/spatie-laravel-media-library` (for media-heavy workflows) or `filament/filament-forms-table` extensions. For a simpler solution, you could build a custom widget using Filament’s `Input` or `Select` fields with CSS styling. However, this package offers a polished, ready-to-use UI tailored specifically for Filament.