First, pull in the package through Composer.
"require": {
"draperstudio/laravel-voteable": "~1.0"
}
And then include the service provider within app/config/app.php
.
'providers' => [
DraperStudio\Voteable\VoteableServiceProvider::class
];
At last you need to publish and run the migration.
php artisan vendor:publish --provider="DraperStudio\Voteable\VoteableServiceProvider" && php artisan migrate
<?php
namespace App;
use DraperStudio\Voteable\Traits\HasVote;
use DraperStudio\Voteable\Traits\HasVoteInterface;
use Illuminate\Database\Eloquent\Model;
class User extends Model implements HasVoteInterface
{
use HasVote;
}
Vote::sum($user);
Vote::count($user);
Vote::countUps($user);
Vote::countDowns($user);
Vote::countByDate($user, '2015-06-30', '2015-06-31');
Vote::up($user);
Vote::down($user);