Download the PHP package packstub/filament-rating without Composer

On this page you can find all versions of the php package packstub/filament-rating. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-rating

Filament Rating

![Filament Rating: star ratings for Filament](https://raw.githubusercontent.com/packstub/art/main/filament-rating/banner.jpg) [![Latest Version on Packagist](https://img.shields.io/packagist/v/packstub/filament-rating.svg?style=flat-square)](https://packagist.org/packages/packstub/filament-rating) [![Tests](https://img.shields.io/github/actions/workflow/status/packstub/filament-rating/tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/packstub/filament-rating/actions/workflows/tests.yml) [![Total Downloads](https://img.shields.io/packagist/dt/packstub/filament-rating.svg?style=flat-square)](https://packagist.org/packages/packstub/filament-rating) [![License](https://img.shields.io/packagist/l/packstub/filament-rating.svg?style=flat-square)](https://github.com/packstub/filament-rating/blob/main/LICENSE.md) [![Listed on filamentphp.com](https://img.shields.io/badge/filamentphp.com-listed-fb7185?style=flat-square&logo=filament&logoColor=white)](https://filamentphp.com/plugins/packstub-rating) [![Sponsor](https://img.shields.io/badge/sponsor-%E2%9D%A4-ea4aaa?style=flat-square&logo=githubsponsors&logoColor=white)](https://github.com/sponsors/icaliman)

Star ratings for Filament v4 and v5: a form field, a table column you can rate from, an infolist entry, a rating filter, and average and distribution summarizers. It supports half stars, labels, colors by value, keyboard and screen readers, dark mode and RTL, and needs no npm build.

It is also a drop-in replacement for mokhosh/filament-rating: the same methods, the same data, and the old Mokhosh\FilamentRating\... imports keep working (see Migrating from mokhosh/filament-rating).

Star ratings in Filament: the review form's stars hovered one by one, the label and color following, four given; then a team score rated straight from the products table

Features

Compatibility

Plugin Filament Livewire Laravel PHP
0.x 4.x, 5.x 3.x, 4.x 11.x – 13.x 8.2+

Installation

filament:assets publishes the plugin's CSS and its small Alpine component. Filament already runs it on composer update if you use its post-autoload-dump script. You don't need to register a panel plugin, rebuild a theme or run npm.

Outside a panel (a plain Livewire component using Filament forms), the assets load with the usual @filamentStyles and @filamentScripts directives in your layout.

Usage

Form field

The rating field in a Filament form: four stars hovered, green, with the label

The state is an integer from 1 to stars() (or 0 with allowZero(), or 0.5 steps with allowHalf()), and null when nothing is picked. It fits an integer (or decimal) column.

Keyboard: arrow keys move by one step (they follow the reading direction in RTL), Home and End jump to the minimum and maximum, and Delete or Backspace clears when clearable().

The field validates itself: numeric, min (0 or the first step), max (the number of stars), and integer or multiple_of:0.5. Screen readers get a radiogroup of radio buttons (a slider in half-star mode) with "3 of 5 stars" labels, the stars take one tab stop, and the focused star shows a ring.

Table column

A products table: each product's average customer rating as partially filled stars with the value and the number of reviews, and a team score rated right in the table

Show an average with its value and the number of ratings:

Labels

Give each rating a word. The field shows the word of the hovered or picked rating next to the stars, and every star is announced as "Very good, 4 of 5 stars":

With allowHalf(), half values can have their own label ('3.5' => 'Pretty good'). Columns, entries and summarizers use the labels for screen readers, and showLabel() prints the label of the nearest rating next to the stars (an average of 3.7 shows "Very good").

Colors by value

Each key is the lowest rating that uses its color; ratings below the lowest key use color(). In the field, the color follows the hover. Any value color() accepts works here too.

Editable table column

RatingInputColumn lets people rate records right in the table, like Filament's ToggleColumn. A click is validated (the same rules as the field) and saved to the record, and an invalid value is rolled back with the error shown on the stars.

It takes every column option (stars, half stars, colors, labels, icons, size) plus rules(), beforeStateUpdated(), afterStateUpdated() and updateStateUsing(). Like Filament's own editable columns it does not check model policies, so use disabled() to decide who may change a rating.

Filter

The reviews table filtered to

RatingFilter is a SelectFilter, so its options work as usual (label(), default(), query()). With exact(), half ratings count toward the star they fill (3.5 matches 3).

Average summarizer

The reviews table with its summary: the average rating as partly filled stars with the value

RatingAverage draws the column's average as stars with the value next to them. It takes the column's stars, colors, icons and size unless you set them on the summarizer.

Rating distribution

The reviews table with its summary: a bar per rating with its count, from five stars down

Pass both summarizers (->summarize([RatingAverage::make(), RatingDistribution::make()])) to show the average above the bars. RatingDistribution draws a bar for each rating from the highest down, with its count (or share with percentages()). Half ratings count toward the star they fill, and a zero row is added with allowZero(). It takes the column's stars, colors (including colors()), icon and labels.

Infolist entry

A review's page: the rating entry with its label,

Customization

All options are available on the field, the column, the entry and the summarizer, and each one accepts a closure.

Method Default Notes
stars(int) 5 Number of stars, also the validation max.
allowZero(bool) false Allows 0; the field shows a "no stars" button, displays show a no-symbol icon.
allowHalf(bool) false Half-star steps in the field.
size(string\|IconSize) md xs 12px, sm 16px, md 24px, lg 32px, xl 40px, 2xl 48px.
color(string\|array) primary Registered color, Tailwind palette name, Color::Amber, or #f59e0b.
emptyColor(string\|array) gray Color of the unfilled part.
icon(...) solid star Any icon Filament accepts: a Blade icon name, a Heroicon case, an Htmlable.
emptyIcon(...) the filled icon For example emptyIcon('heroicon-o-star') for outlined empty stars.
theme(RatingTheme) Simple HalfStars: half steps in the field and rounded-down halves in displays (kept from mokhosh).
colors(array) none Color per rating: [min rating => color].
labels(array) none A word per rating, used by the field's caption and screen readers.
showValue(), precision(int), showCount(int), showLabel() off, 1, none, off Column, entry and summarizer only.
clearable() off Field and RatingInputColumn.
readOnly() off Field only.

To change the icons everywhere, register their aliases in a service provider:

The reviews table in dark mode, its ratings drawn as hearts through the icon aliases

The stars use their own plain CSS, so there's nothing to add to a custom theme. If you style the fi-rating-* classes with Tailwind in your theme, add the views to its sources:

The strings (screen reader labels, the clear button, the filter and summarizer captions) live in a language file, with English and Romanian included. Publish them with php artisan vendor:publish --tag=filament-rating-translations.

Migrating from mokhosh/filament-rating

The plugin keeps mokhosh v2's public API, so moving over takes three steps:

  1. Your existing use Mokhosh\FilamentRating\... imports keep working: the package aliases those five classes to its own. Aliases are created lazily and only when mokhosh itself isn't installed.
  2. When convenient, switch the imports to the new namespace (a search and replace of Mokhosh\FilamentRating with Packstub\FilamentRating).
  3. Delete the old published assets, public/css/mokhosh and public/js/mokhosh.
mokhosh v2 packstub/filament-rating
Mokhosh\FilamentRating\Components\Rating Packstub\FilamentRating\Components\Rating
Mokhosh\FilamentRating\Columns\RatingColumn Packstub\FilamentRating\Columns\RatingColumn
Mokhosh\FilamentRating\Entries\RatingEntry Packstub\FilamentRating\Entries\RatingEntry
Mokhosh\FilamentRating\RatingTheme Packstub\FilamentRating\RatingTheme (same cases)
Mokhosh\FilamentRating\FilamentRatingPlugin Packstub\FilamentRating\FilamentRatingPlugin (same id, optional)
stars(int), getStars(), getStarsArray() same, also accepts a closure
allowZero(), shouldAllowZero() same
size('xs'…'xl'), getSize() same sizes in pixels, plus 2xl and IconSize
color('primary'), getColor() same, plus palette names, Color::* arrays and hex
theme(RatingTheme::HalfStars), getTheme() same; allowHalf() is the explicit spelling
php artisan filament-rating:install same command (publishes the assets)

A few things behave differently:

Documentation

The full guide lives at packstub.dev/docs/filament-rating, and the same page is in the docs/ directory of this repository.

Testing

Changelog

See CHANGELOG.

Contributing

See CONTRIBUTING.

Security

See our security policy.

Credits

License

The MIT License (MIT). See LICENSE.


All versions of filament-rating with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
filament/filament Version ^4.0 || ^5.0
spatie/laravel-package-tools Version ^1.92
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package packstub/filament-rating contains the following files

Loading the files please wait ...