roundly-consulting / reviews-for-laravel
Write reviews to any entity from any entity.
Package info
github.com/roundly-consulting/reviews-for-laravel
pkg:composer/roundly-consulting/reviews-for-laravel
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/contracts: ^12.0|^13.0
- roundly-consulting/enums-for-laravel: ^1.0
- roundly-consulting/media-library-for-laravel: ^1.0
- roundly-consulting/package-toolkit-for-laravel: ^1.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- roundly-consulting/testing-for-laravel: ^1.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Reviews for Laravel
Ratings and reviews for any Eloquent model — users review products, businesses review users, anything can review anything. Star ratings, a moderation lifecycle, verified purchases, helpful votes, owner responses, review photos and cached aggregates, behind one fluent facade.
Installation
Requires PHP 8.4 and Laravel 12 or 13.
composer require roundly-consulting/reviews-for-laravel php artisan vendor:publish --tag="reviews-migrations" php artisan vendor:publish --tag="media-migrations" # review photos live in media-library php artisan migrate
If the models being reviewed, writing reviews or voting have UUID/ULID keys, set
REVIEWS_KEY_TYPE=uuid (or ulid) before migrating.
Usage
Make a model reviewable and another one a reviewer:
use RoundlyConsulting\Reviews\Concerns\CanReview; use RoundlyConsulting\Reviews\Concerns\HasReviews; class Product extends Model { use HasReviews; } class User extends Authenticatable { use CanReview; }
Then write, moderate and read reviews:
use RoundlyConsulting\Reviews\Facades\Reviews; $review = Reviews::for($product)->by($user) ->rating(5) ->title('Loved it') ->content('Great value for the price') ->verified() // a verified purchase ->create(); // lands as pending Reviews::approve($review); Reviews::respond($review, $owner, 'Thanks for the feedback!'); Reviews::vote($review, $shopper, helpful: true); Reviews::for($product)->average(); // 5.0 Reviews::for($product)->distribution(); // [5 => 1] Reviews::for($product)->query()->approved()->mostHelpful()->paginate();
Documentation
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/reviews-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
Support our work
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
License
The MIT License (MIT). Please see License File for more information.