se468/laravel-ratings is a Laravel package for laravel ratings engine.
It currently has 1 GitHub stars and 13 downloads on Packagist (latest version v0.0.1).
Install it with composer require se468/laravel-ratings.
Discover more Laravel packages by se468
or browse all Laravel packages to compare alternatives.
Last updated
Ratings engine for Laravel using polymorphic relationships.
DEMO : here
composer require se468/laravel-ratingsphp artisan migrate to migrate the tablesCanReceiveRatings trait to your model that receives Ratings (App\User, App\Company, App\Project .. whatever you need to receive ratings for) and implement RatingReceivable interface to the model.CanGiveRatings trait to your model that needs to give Ratings (Usually App\User).Example (CanGiveRatings):
<?php
namespace App;
use se468\Ratings\RatingGivable;
...
class User extends Authenticatable
{
use CanGiveRating;
...
}
Example (CanReceiveRatings):
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use se468\Ratings\RatingReceivable;
use se468\Ratings\Traits\CanReceiveRating;
...
class Company extends Model implements RatingReceivable
{
use CanReceiveRating;
...
}
public function rateCompany(Request $request)
{
$input = $request->all();
$company = Company::find($input["id"]);
auth()->user()->rate($company, $input["rating"], 'Some Comment');
return redirect()->back();
}
ratingsReceived() - morphMany to Ratings
getOverallRating()
ratingsGiven() - hasMany to Ratings
rate(RatingReceivable $ratable, $ratingValue)
You can change rater function in Rating model if you want something other than App\User to give ratings.