laravel-ratings maintained by pharaonic
Description
Polymorphic ratings for Laravel Eloquent models: one rating per rater and target, configurable scales, optional comments, and database-enforced uniqueness.
Author
Last update
2026/12/04 13:44
(6.x-dev)
License
Downloads
2
Last update
2026/12/04 13:44
License
Require
- php >=8.0 <8.1
- illuminate/contracts ^6.20
- illuminate/database ^6.20
- illuminate/support ^6.20
- illuminate/events ^6.20
- illuminate/translation ^6.20
Last update
2026/12/04 13:44
License
Require
- php >=8.0 <8.1
- illuminate/contracts ^7.30
- illuminate/database ^7.30
- illuminate/support ^7.30
- illuminate/events ^7.30
- illuminate/translation ^7.30
Last update
2026/12/04 13:44
License
Require
- php >=8.0 <8.2
- illuminate/contracts ^8.75
- illuminate/database ^8.75
- illuminate/support ^8.75
- illuminate/events ^8.75
- illuminate/translation ^8.75
Last update
2026/12/04 13:44
License
Require
- php >=8.0 <8.3
- illuminate/contracts ^9.33
- illuminate/database ^9.33
- illuminate/support ^9.33
- illuminate/events ^9.33
- illuminate/translation ^9.33
Last update
2026/12/04 13:43
License
Require
- php >=8.1 <8.4
- illuminate/contracts ^10.0
- illuminate/database ^10.0
- illuminate/support ^10.0
- illuminate/events ^10.0
- illuminate/translation ^10.0
Last update
2026/12/04 13:43
License
Require
- php >=8.2 <8.5
- illuminate/contracts ^11.0
- illuminate/database ^11.0
- illuminate/support ^11.0
- illuminate/events ^11.0
- illuminate/translation ^11.0
Last update
2026/12/04 13:43
License
Require
- php >=8.2 <8.6
- illuminate/contracts ^12.0
- illuminate/database ^12.0
- illuminate/support ^12.0
- illuminate/events ^12.0
- illuminate/translation ^12.0
Last update
2026/12/04 13:43
License
Require
- php >=8.3 <8.6
- illuminate/contracts ^13.0
- illuminate/database ^13.0
- illuminate/support ^13.0
- illuminate/events ^13.0
- illuminate/translation ^13.0
Last update
2026/12/04 12:07
Require
- illuminate/contracts ^13.0
- illuminate/database ^13.0
- illuminate/events ^13.0
- illuminate/support ^13.0
- illuminate/translation ^13.0
- php >=8.3 <8.7
Last update
2026/12/04 10:56
License
Require
- php >=8.3 <8.6
- illuminate/contracts ^13.0
- illuminate/database ^13.0
- illuminate/support ^13.0
Last update
2026/12/04 10:09
Require
- php >=8.2 <8.6
- illuminate/contracts ^12.0
- illuminate/database ^12.0
- illuminate/events ^12.0
- illuminate/support ^12.0
- illuminate/translation ^12.0
Last update
2026/12/04 10:09
Require
- php >=8.2 <8.5
- illuminate/contracts ^11.0
- illuminate/database ^11.0
- illuminate/events ^11.0
- illuminate/support ^11.0
- illuminate/translation ^11.0
Last update
2026/12/04 10:09
Require
- php >=8.1 <8.4
- illuminate/contracts ^10.0
- illuminate/database ^10.0
- illuminate/events ^10.0
- illuminate/support ^10.0
- illuminate/translation ^10.0
Last update
2026/12/04 10:09
Require
- php >=8.0 <8.3
- illuminate/contracts ^9.33
- illuminate/database ^9.33
- illuminate/events ^9.33
- illuminate/support ^9.33
- illuminate/translation ^9.33
Last update
2026/12/04 09:30
Require
- php >=8.0 <8.2
- illuminate/contracts ^8.75
- illuminate/database ^8.75
- illuminate/events ^8.75
- illuminate/support ^8.75
- illuminate/translation ^8.75
Last update
2026/12/04 09:30
Require
- php >=8.0 <8.1
- illuminate/contracts ^7.30
- illuminate/database ^7.30
- illuminate/events ^7.30
- illuminate/support ^7.30
- illuminate/translation ^7.30
Last update
2026/12/04 09:30
Require
- php >=8.0 <8.1
- illuminate/contracts ^6.20
- illuminate/database ^6.20
- illuminate/events ^6.20
- illuminate/support ^6.20
- illuminate/translation ^6.20
Last update
2026/12/04 08:43
License
Require
- php >=8.3 <8.6
- illuminate/contracts ^13.0
- illuminate/database ^13.0
- illuminate/events ^13.0
- illuminate/support ^13.0
- illuminate/translation ^13.0
Last update
2026/12/04 08:43
Require
- php >=8.2 <8.6
- illuminate/contracts ^12.0
- illuminate/database ^12.0
- illuminate/events ^12.0
- illuminate/support ^12.0
- illuminate/translation ^12.0
Last update
2026/12/04 08:43
Require
- php >=8.2 <8.5
- illuminate/contracts ^11.0
- illuminate/database ^11.0
- illuminate/events ^11.0
- illuminate/support ^11.0
- illuminate/translation ^11.0
Last update
2026/12/04 08:42
Require
- php >=8.1 <8.4
- illuminate/contracts ^10.0
- illuminate/database ^10.0
- illuminate/events ^10.0
- illuminate/support ^10.0
- illuminate/translation ^10.0
Last update
2026/12/04 08:42
Require
- php >=8.0 <8.3
- illuminate/contracts ^9.33
- illuminate/database ^9.33
- illuminate/events ^9.33
- illuminate/support ^9.33
- illuminate/translation ^9.33
Last update
2026/12/04 08:42
Require
- php >=8.0 <8.2
- illuminate/contracts ^8.75
- illuminate/database ^8.75
- illuminate/events ^8.75
- illuminate/support ^8.75
- illuminate/translation ^8.75
Last update
2026/12/04 08:42
Require
- php >=8.0 <8.1
- illuminate/contracts ^7.30
- illuminate/database ^7.30
- illuminate/events ^7.30
- illuminate/support ^7.30
- illuminate/translation ^7.30
Last update
2026/12/04 08:42
Require
- php >=8.0 <8.1
- illuminate/contracts ^6.20
- illuminate/database ^6.20
- illuminate/events ^6.20
- illuminate/support ^6.20
- illuminate/translation ^6.20
Last update
2026/12/04 07:09
License
Require
- php >=8.3 <8.6
- illuminate/contracts ^13.0
- illuminate/database ^13.0
- illuminate/events ^13.0
- illuminate/support ^13.0
- illuminate/translation ^13.0
Last update
2026/12/04 07:09
License
Require
- php >=8.3 <8.6
- illuminate/contracts ^13.0
- illuminate/database ^13.0
- illuminate/support ^13.0
Last update
2026/12/04 00:38
License
Require
- php >=8.3 <8.6
- illuminate/contracts ^13.0
- illuminate/database ^13.0
- illuminate/events ^13.0
- illuminate/support ^13.0
- illuminate/translation ^13.0
Last update
2026/12/04 00:29
License
Require
- php >=8.2 <8.6
- illuminate/contracts ^12.0
- illuminate/database ^12.0
- illuminate/events ^12.0
- illuminate/support ^12.0
- illuminate/translation ^12.0
Last update
2026/12/04 00:13
License
Require
- php >=8.2 <8.5
- illuminate/contracts ^11.0
- illuminate/database ^11.0
- illuminate/events ^11.0
- illuminate/support ^11.0
- illuminate/translation ^11.0
Last update
2026/12/04 00:01
License
Require
- php >=8.1 <8.4
- illuminate/contracts ^10.0
- illuminate/database ^10.0
- illuminate/events ^10.0
- illuminate/support ^10.0
- illuminate/translation ^10.0
Last update
2026/12/03 23:48
License
Require
- php >=8.0 <8.3
- illuminate/contracts ^9.33
- illuminate/database ^9.33
- illuminate/events ^9.33
- illuminate/support ^9.33
- illuminate/translation ^9.33
Last update
2026/12/03 23:37
License
Require
- php >=8.0 <8.2
- illuminate/contracts ^8.75
- illuminate/database ^8.75
- illuminate/events ^8.75
- illuminate/support ^8.75
- illuminate/translation ^8.75
Last update
2026/12/03 22:57
License
Require
- php >=8.0 <8.1
- illuminate/contracts ^7.30
- illuminate/database ^7.30
- illuminate/events ^7.30
- illuminate/support ^7.30
- illuminate/translation ^7.30
Last update
2026/12/03 17:53
License
Require
- php >=8.0 <8.1
- illuminate/contracts ^6.20
- illuminate/database ^6.20
- illuminate/events ^6.20
- illuminate/support ^6.20
- illuminate/translation ^6.20
Last update
2026/11/13 16:27
License
Require
- php >=8.3 <8.6
- illuminate/contracts ^13.0
- illuminate/database ^13.0
- illuminate/support ^13.0
Last update
2026/11/13 16:27
License
Require
- php >=8.2 <8.6
- illuminate/contracts ^12.0
- illuminate/database ^12.0
- illuminate/support ^12.0
Last update
2026/11/13 16:27
License
Require
- php >=8.2 <8.5
- illuminate/contracts ^11.0
- illuminate/database ^11.0
- illuminate/support ^11.0
Last update
2026/11/13 16:26
License
Require
- php >=8.1 <8.4
- illuminate/contracts ^10.0
- illuminate/database ^10.0
- illuminate/support ^10.0
Last update
2026/11/13 16:26
License
Require
- php >=8.0 <8.3
- illuminate/contracts ^9.33
- illuminate/database ^9.33
- illuminate/support ^9.33
Last update
2026/11/13 16:26
License
Require
- php >=8.0 <8.2
- illuminate/contracts ^8.75
- illuminate/database ^8.75
- illuminate/support ^8.75
Last update
2026/11/13 16:26
License
Require
- php >=8.0 <8.1
- illuminate/contracts ^7.30
- illuminate/database ^7.30
- illuminate/support ^7.30
Last update
2026/11/13 16:26
License
Require
- php >=8.0 <8.1
- illuminate/contracts ^6.20
- illuminate/database ^6.20
- illuminate/support ^6.20
Last update
2026/11/13 16:00
License
Require
- php >=8.1 <8.4
- illuminate/contracts ^10.0
- illuminate/database ^10.0
- illuminate/support ^10.0
Last update
2026/11/13 16:00
License
Require
- php >=8.0 <8.3
- illuminate/contracts ^9.33
- illuminate/database ^9.33
- illuminate/support ^9.33
Last update
2026/11/13 15:59
License
Require
- php >=8.0 <8.2
- illuminate/contracts ^8.75
- illuminate/database ^8.75
- illuminate/support ^8.75
Last update
2026/11/13 15:59
License
Require
- php >=8.0 <8.1
- illuminate/contracts ^7.30
- illuminate/database ^7.30
- illuminate/support ^7.30
Last update
2026/11/13 15:59
License
Require
- php >=8.0 <8.1
- illuminate/contracts ^6.20
- illuminate/database ^6.20
- illuminate/support ^6.20
Last update
2026/11/13 14:55
License
Require
- php >=8.0 <8.1
- illuminate/contracts ^6.20
- illuminate/database ^6.20
- illuminate/support ^6.20
Last update
2026/11/13 14:55
License
Require
- php >=8.0 <8.1
- illuminate/contracts ^7.30
- illuminate/database ^7.30
- illuminate/support ^7.30
Installation
composer require pharaonic/laravel-ratings
php artisan migrate
The service provider is registered automatically, and migrate creates the ratings table. Publish the migration only to change it (--tag=ratings-migrations), and the configuration only to rename the table, change the default 1 to 5 scale, or turn off cleanup on delete:
php artisan vendor:publish --tag=ratings-config
Usage
Add CanRate to the model that rates (it does not have to be a user) and HasRatings to the model that is rated. A model can use both.
use Illuminate\Foundation\Auth\User as Authenticatable;
use Pharaonic\Laravel\Ratings\Concerns\CanRate;
class User extends Authenticatable
{
use CanRate;
}
use Illuminate\Database\Eloquent\Model;
use Pharaonic\Laravel\Ratings\Concerns\HasRatings;
class Product extends Model
{
use HasRatings;
}
$result = $user->rate($product, 4, 'Nice product'); // creates the rating
$result->created(); // true
$result->current(); // 4
$result = $user->rate($product, 5); // updates it, and keeps 'Nice product'
$result->updated(); // true
$result->previous(); // 4
$user->rate($product, 5)->unchanged(); // true: nothing to write
$user->rate($product, 5, null); // clears the comment
$rating = $user->ratingFor($product); // the Rating model, or null
$rating->update(['comment' => 'Updated review']);
$product->averageRating(); // 5.0, or null without ratings
$product->ratingsCount(); // 1
$product->ratingDistribution(); // [5 => 1]
Product::whereRatingAtLeast(4)->paginate(); // by average rating
Documentation
Full documentation: Laravel Ratings Documentation.
Support & Security
See SUPPORT.md and SECURITY.md. Contributions are welcome; see CONTRIBUTING.md.
License
MIT. See LICENSE.