1. Go to this page and download the library: Download compubel/laravel-rating library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
compubel / laravel-rating example snippets
Compubel\Rating\RatingServiceProvider::class,
use Compubel\Rating\CanRate;
use Compubel\Rating\Contracts\Rater;
class User extends Model implements Rater
{
use CanRate;
// ...
}
use Compubel\Rating\CanBeRated;
use Compubel\Rating\Contracts\Rateable;
class Post extends Model implements Rateable
{
use CanBeRated;
// ...
}
use Compubel\Rating\Rate;
use Compubel\Rating\Contracts\Rating;
class Member extends Model implements Rating
{
use Rate;
// ...
}
$user->rate($post, 10);
$post->averageRating(User::class); // 10.0, as float