PHP code example of agilepixels / laravel-rateable
1. Go to this page and download the library: Download agilepixels/laravel-rateable 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/ */
agilepixels / laravel-rateable example snippets
// Add a rating for a model
$model->createRating($rating = 4, $author = $user, $body = 'Very nice!');
// Calculate the average rating for a model
$model->averageRating();
// Sum the ratings for a model
$model->sumRating();
namespace App;
use Illuminate\Database\Eloquent\Model;
use AgilePixels\Rateable\Traits\HasRating;
class Product extends Model
{
use HasRating;
}
namespace App;
use Illuminate\Database\Eloquent\Model;
use AgilePixels\Rateable\Traits\AddsRating;
class User extends Model
{
use AddsRating;
}