Skip to content

thomaswardiii/Laravel-Voteable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Voteable

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::class
];

At last you need to publish and run the migration.

php artisan vendor:publish --provider="DraperStudio\Voteable\VoteableServiceProvider" && php artisan migrate

Setup a Model

<?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;
}

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);

About

Use At Your Own Risk - Not Maintained!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%