Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Rating Laravel Package

cjmellor/rating

A Laravel package for adding ratings and reviews to your models. Supports polymorphic relationships, multiple rating types, and easy Eloquent integration, letting you attach star ratings or reviews to users, posts, products, and more.

View on GitHub
Deep Wiki
Context7

A Laravel package that allows for ratings to be added to a Model

Frequently asked questions about Rating
How do I install and set up cjmellor/rating in a Laravel app?
Install it with composer require cjmellor/rating, publish the package config and migrations, then run php artisan migrate. Add the package's rateable trait and interface to each model that should receive ratings. No Livewire install is required unless you plan to use the optional star-rating component.
Which Laravel and PHP versions does cjmellor/rating support?
The package targets Laravel 10.48+ and Laravel 11.x on PHP 8.1 through 8.3. Its test matrix uses Orchestra Testbench against the current Laravel line. Check the composer constraints before upgrading if you are on older Laravel or PHP versions.
How do I add ratings to an Eloquent model with cjmellor/rating?
Add the package's trait and interface to your Eloquent model, then create ratings through the package's rating relationship or helper methods. Ratings are stored in a polymorphic table, so the same model can be rated by users and other models. You can then query ratings or use the package's aggregation helpers for averages and counts.
Does cjmellor/rating support multiple rating types or reviews?
Yes. cjmellor/rating supports multiple rating types and polymorphic relationships, so you can attach star ratings or reviews to users, posts, products, and other models. This lets you separate rating categories or use one ratings table for several rateable models. Review the published config for any type-specific options.
Is Livewire required to use cjmellor/rating?
No. As of v2.2.0, Livewire is no longer a required dependency of cjmellor/rating; it is an optional presentation layer. API-first, Inertia/Vue, and Blade apps that do not use Livewire can rely on the trait, ratings table, and aggregation helpers alone. If you use the shipped star component, add livewire/livewire explicitly to your root composer.json.
What changed in cjmellor/rating 2.2.0 and is it a breaking change?
v2.2.0 removes Livewire from the package's required dependencies, which is a soft breaking change for apps that relied on it arriving transitively. No new config keys, migrations, or public API changes are announced for this release. Apps that do not render the Livewire component should be unaffected, but verify the service provider guards component registration.
How do I upgrade from cjmellor/rating 2.1.x to 2.2.0 safely?
If you use the Livewire component, add livewire/livewire to your root composer.json before upgrading. Run composer update cjmellor/rating --with-dependencies in a branch and diff the lockfile to confirm Livewire is retained or intentionally removed. Diff published config and views against the vendor files, run migrations only if new migration files appear, and verify the component alias still resolves when the widget is in use.
Does cjmellor/rating work in API-only or Inertia apps without Livewire?
Yes. The v2.2.0 dependency change makes cjmellor/rating viable for API-only and Inertia/Vue stacks because Livewire is no longer pulled in transitively. You still get the polymorphic ratings table, Eloquent trait, and aggregation methods. Only install Livewire if you want the optional star-rating UI.
How should I test cjmellor/rating in my Laravel test suite?
Use RefreshDatabase in your Laravel tests, attach ratings to models via the package trait, and assert the rating records and aggregate values you expect. Test against an explicit matrix such as Laravel 10.48 and 11.x on PHP 8.2 and 8.3 with MySQL, Postgres, and SQLite. If you use the Livewire component, include a Livewire-present axis in your test matrix.
When should I use cjmellor/rating instead of building ratings myself?
Use cjmellor/rating when you want a trait-based polymorphic ratings table with optional Livewire presentation rather than building rating models, migrations, and aggregation queries yourself. A custom implementation may be preferable if you need highly specialized review workflows or schema constraints not covered by the package. Evaluate the published migration and config first, especially around duplicate-rating constraints and rating types.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections