Download the PHP package muyaedward/rateable-laravel without Composer
On this page you can find all versions of the php package muyaedward/rateable-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package rateable-laravel
Rateable Laravel
Provides a trait to allow rating of any Eloquent models within your app for Laravel 5.
Ratings could be fivestar style, or simple +1/-1 style.
Installation
Require the package using Composer:
As with most Laravel packages, if you're using Laravel 5.5 or later, the package will be auto-discovered (learn more if this is new to you).
If you're using a version of Laravel before 5.5, you'll need to register the Rateable service provider. In your config/app.php
add 'muyaedward\Rateable\RateableServiceProvider'
to the end of the $providers
array.
``
Getting started
After the package is correctly installed, you need to generate the migration. `
It will generate the <timestamp>_create_ratings_table.php
migration. You may now run it with the artisan migrate command:
`
After the migration, one new table will be present, ratings
.
Usage
In order to mark a model as "rateable", import the Rateable
trait.
``
Now, your model has access to a few additional methods.
First, to add a rating to your model:
``
Once a model has some ratings, you can fetch the average rating: ``
Also, you can fetch the rating percentage. This is also how you enforce a maximum rating value.
``
You can also fetch the sum or average of ratings for the given rateable item the current (authorized) has voted/rated. ``
All versions of rateable-laravel with dependencies
illuminate/support Version ^5.5|^6.0|^6.1|^6.2|^6.3|^6.4|^6.5|^6.6
illuminate/database Version ^5.5|^6.0|^6.1|^6.2|^6.3|^6.4|^6.5|^6.6