lartisan / filament-rating-tool
Rating Tool is a FilamentPHP plugin meant to provide a set of tools for measuring or rating different resources of your app.
Fund package maintenance!
lartisan
Installs: 48
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
Open Issues: 2
Language:Blade
Requires
- php: ^8.1
- filament/filament: ^3.0
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2024-11-08 07:29:29 UTC
README
Filament Rating Tool is a FilamentPHP plugin meant to provide a set of tools for measuring or rating different resources of your app.
What's different from other (star) rating tools?
Well, we thought of giving a user the possibility to choose an icon, depending on the context of the rating.
For example, if you want to rate a movie, you can use a star icon, if you want to rate a book, you can use a book icon, if you want to provide the number of persons that can occupy a hotel room, you can use a user icon ... and so on, you get the idea. Any icon provided by Filament can be user for rating / measuring.
Also, we made it possible for a user to choose their on size for the icons, the number of icons to be displayed and also the color for the icons. Yeah, you can set different colors for the icons, depending on the rating value.
You can check some examples below or try it yourself on the demo app.
Installation
You can install the package via composer:
composer require lartisan/filament-rating-tool
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-rating-tool-views"
Form Usage
When preparing a form, you need to define a RatingInput
field and, optionally, make some configurations:
RatingInput::make('rating') ->size('xl') ->maxValue(5) ->icon('heroicon-o-stop') ->color(fn (int $state): string => match ($state) { 1 => 'danger', 2 => 'warning', 3 => 'info', 4 => 'primary', 5 => 'success', default => 'gray', }),
These are all the possible methods one can use to configure this field. As you can see, you can provide a maxValue
for your input, so if you want to match some custom color based on the $state
, you'll need the same amount of colors. Of course, one can only choose one color for all the symbols of the field
RatingInput::make('rating') ->color('warning') // ...
Table Usage
Similar to forms, there is a dedicated column for displaying the measurement value...
RatingColumn::make('rating') ->size('xs') ->maxValue(5) ->icon('heroicon-s-star') ->color(fn (int $state): string => match ($state) { 1 => 'danger', 2 => 'warning', 3 => 'info', 4 => 'primary', 5 => 'success', default => 'gray', }), // ...
Infolist Usage
... and another one to display the infolist when viewing the records
RatingEntry::make('rating') ->columnSpan(2) ->size('lg') ->maxValue(5) ->icon('heroicon-s-user') ->color(fn (int $state): string => match ($state) { 1 => 'danger', 2 => 'warning', 3 => 'info', 4 => 'primary', 5 => 'success', default => 'gray', }), // ...
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.