Download the PHP package codebyray/laravel-review-rateable without Composer
On this page you can find all versions of the php package codebyray/laravel-review-rateable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codebyray/laravel-review-rateable
More information about codebyray/laravel-review-rateable
Files in codebyray/laravel-review-rateable
Package laravel-review-rateable
Short Description Review & Rating system for Laravel 10, 11 & 12
License MIT
Rated 3.45 based on 11 reviews
Informations about the package laravel-review-rateable
Laravel Review Rateable
NOTE: This is a complete rewrite from v1. It is not compatible with previous versions of this package.
Laravel Review Ratable is a flexible package that enables you to attach reviews (with multiple ratings) to any Eloquent model in your Laravel application. The package supports multiple departments, configurable rating boundaries, review approval, and a decoupled service contract so you can easily integrate, test, and extend the functionality.
Features
- Polymorphic Reviews & Ratings: Attach written reviews along with multiple rating values to any model.
- Configurable Settings: Define custom rating keys, labels, and value boundaries (min/max) via a config file.
- Department Support: Organize ratings by department (e.g. default, sales, support) with their own criteria.
- Review Approval: Set a default approval status for reviews (and override per review if needed).
- Flexible Data Retrieval: Retrieve reviews with or without ratings, filter by approval status, and calculate averages.
- Service Contract: Use a dedicated service that implements a contract for a decoupled, testable API.
Requirements
- PHP 8.1 or higher
- Laravel 10, 11, or 12
Installation
1. Install via Composer
In your Laravel application's root, require the package via Composer.
2. Publish Package Assets
After installation, publish the package config and migration files:
Run the migrations to create the necessary database tables:
Configuration
The package configuration file is located at config/laravel-review-ratable.php. Here you can adjust global settings such as:
- Rating Value Boundaries:
- min_rating_value: Minimum rating value.
- max_rating_value: Maximum rating value.
- Review Approval:
- review_approved: Default approval status for new reviews.
- Departments & Rating Labels: Define multiple departments, each with its own set of rating keys and labels.
Example configuration:
Usage
Making a Model Reviewable
To allow a model to be reviewed, add the ReviewRateable
trait to your model. For example, in your Product
model:
Adding a review/rating(s)
You can add a review (with ratings) directly via the trait:
Update a review/rating(s)
Marking review as approved
Delete a review/rating:
Fetch approved or not approved reviews/ratings for a particular resource
Fetch the average rating:
Get all reviews with or without ratings:
Count total number of reviews:
``
Example Usage in a Controller
Every method available using the ReviewRateable Trait can also be called via the service
Testing
Notes
All versions of laravel-review-rateable with dependencies
illuminate/config Version ^10.0 || ^11.0 || ^12.0
illuminate/database Version ^10.0 || ^11.0 || ^12.0
illuminate/support Version ^10.0 || ^11.0 || ^12.0