1. Go to this page and download the library: Download canylmz/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/ */
canylmz / laravel-rating example snippets
Canylmz\Rating\RatingServiceProvider::class,
use Canylmz\Rating\CanRate;
use Canylmz\Rating\Contracts\Rater;
class User extends Model implements Rater
{
use CanRate;
// ...
}
use Canylmz\Rating\CanBeRated;
use Canylmz\Rating\Contracts\Rateable;
class Post extends Model implements Rateable
{
use CanBeRated;
// ...
}
use Canylmz\Rating\Rate;
use Canylmz\Rating\Contracts\Rating;
class Member extends Model implements Rating
{
use Rate;
// ...
}
$user->rate($post, 10);
$post->averageRating(User::class); // 10.0, as float