PHPackages                             centrex/laravel-ratings - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. centrex/laravel-ratings

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

centrex/laravel-ratings
=======================

Add rating to any model in laravel

v2.0.0(8mo ago)02.1k[1 PRs](https://github.com/centrex/laravel-ratings/pulls)MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Dec 2Pushed 1w agoCompare

[ Source](https://github.com/centrex/laravel-ratings)[ Packagist](https://packagist.org/packages/centrex/laravel-ratings)[ Docs](https://github.com/centrex/laravel-ratings)[ RSS](/packages/centrex-laravel-ratings/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (15)Versions (16)Used By (0)

Add ratings and reviews to any Eloquent model
=============================================

[](#add-ratings-and-reviews-to-any-eloquent-model)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e2544b3a984d4c53a2d2839f68a50dd7fae90b7db52b60b0770bfae988380fc9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63656e747265782f6c61726176656c2d726174696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/centrex/laravel-ratings)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f5cb849f7fd36fed54a3a78409966a455645303154d65e93666f81f5be36b702/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63656e747265782f6c61726176656c2d726174696e67732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/centrex/laravel-ratings/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/4324345aa5c8934b359a30b8212abebeaa7d1e9dd556c9e9bd5dd85f8f70e276/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63656e747265782f6c61726176656c2d726174696e67732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/centrex/laravel-ratings/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/328cd79f7e5ce1b506c2600174b287df6c5d37483506d568a0f827b05921f8af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63656e747265782f6c61726176656c2d726174696e67733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/centrex/laravel-ratings)

Polymorphic rating and review system for any Eloquent model. Each authenticated user can rate or review a model once. Provides average, sum, and percentage accessors out of the box.

Installation
------------

[](#installation)

```
composer require centrex/laravel-ratings
php artisan vendor:publish --tag="laravel-ratings-migrations"
php artisan migrate
```

Usage
-----

[](#usage)

### 1. Add the traits to your model

[](#1-add-the-traits-to-your-model)

```
use Centrex\LaravelRatings\Concerns\InterectsWithRating;
use Centrex\LaravelRatings\Concerns\InterectsWithReview;

class Product extends Model
{
    use InterectsWithRating;
    use InterectsWithReview;
}
```

### 2. Ratings

[](#2-ratings)

```
// Rate (throws CannotBeRatedException if already rated)
$product->rate(5);

// Remove rating
$product->unrate();

// Check if current user already rated
$product->alreadyRated();  // bool

// Aggregates (computed via Eloquent accessors)
$product->average_rating;          // avg score
$product->sum_rating;              // total score
$product->rated_in_total;          // number of ratings
$product->rated_by_users;          // number of unique users who rated
$product->average_rating_by_user;  // current user's average rating
$product->average_sum_of_user;     // current user's total score

// Percentage out of max (default max from config)
$product->ratingPercent();          // out of config max
$product->ratingPercent(10);        // out of 10
```

### 3. Reviews

[](#3-reviews)

```
// Review (throws CannotBeReviewedException if already reviewed)
$product->review('Excellent build quality, highly recommend!');

// Remove review
$product->unreview();

// Check if current user already reviewed
$product->alreadyReviewed();  // bool

// Get all reviews
$product->reviews;

// Count unique reviewers
$product->reviewed_by_users;
```

### 4. Config

[](#4-config)

```
php artisan vendor:publish --tag="laravel-ratings-config"
```

```
// config/rating.php
'max_rating' => 5,
'users' => [
    'primary_key' => 'user_id',
],
```

Testing
-------

[](#testing)

```
composer test        # full suite
composer test:unit   # pest only
composer test:types  # phpstan
composer lint        # pint
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [centrex](https://github.com/centrex)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance82

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 65.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~77 days

Recently: every ~121 days

Total

10

Last Release

248d ago

Major Versions

v1.3.0 → v2.0.02025-10-29

PHP version history (4 changes)v1.0.0PHP ^8.0|^8.1

v1.0.3PHP ^8.1|^8.2

v1.2.0PHP ^8.1|^8.2|^8.3

v1.3.0PHP ^8.2|^8.3|^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29769944?v=4)[Raisul Islam](/maintainers/rochi88)[@rochi88](https://github.com/rochi88)

---

Top Contributors

[![rochi88](https://avatars.githubusercontent.com/u/29769944?v=4)](https://github.com/rochi88 "rochi88 (44 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (15 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")

---

Tags

laravelratingscentrex

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/centrex-laravel-ratings/health.svg)

```
[![Health](https://phpackages.com/badges/centrex-laravel-ratings/health.svg)](https://phpackages.com/packages/centrex-laravel-ratings)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[livewire/flux

The official UI component library for Livewire.

9527.8M127](/packages/livewire-flux)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
