Skip to content

Latest commit

 

History

History
82 lines (60 loc) · 1.04 KB

README.md

File metadata and controls

82 lines (60 loc) · 1.04 KB

Laravel Voteable

Use At Your Own Risk - Not Maintained!


Installation

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'
];

At last you need to publish and run the migration.

php artisan vendor:publish && php artisan migrate

Setup a Model

<?php

namespace App;

use DraperStudio\Voteable\Traits\Voteable;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use Voteable;
}

Sum of all votes

Vote::sum($user);

Count all votes

Vote::count($user);

Count all up-votes

Vote::countUps($user);

Count all down-votes

Vote::countDowns($user);

Count all votes between two dates

Vote::countByDate($user, '2015-06-30', '2015-06-31');

Up-vote

Vote::up($user);

Down-vote

Vote::down($user);