PHPackages                             daydevelops/vote - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. daydevelops/vote

ActiveLibrary

daydevelops/vote
================

A package built for laravel applications which allows items to be voted on. Items can be upvoted or downvoted which counts towards a total score.

v1.1.0(6y ago)8161MITPHPCI failing

Since Apr 25Pushed 6y ago2 watchersCompare

[ Source](https://github.com/daydevelops/vote)[ Packagist](https://packagist.org/packages/daydevelops/vote)[ Docs](https://github.com/daydevelops/vote)[ RSS](/packages/daydevelops-vote/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (3)Used By (0)

Laravel 7 Vote Package
======================

[](#laravel-7-vote-package)

[![Build Status](https://camo.githubusercontent.com/04b4e7081346f753b6bb659f7af56eef7ce24a5ea26d1a98f946bff337b2fd35/68747470733a2f2f7472617669732d63692e6f72672f646179646576656c6f70732f766f74652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/daydevelops/vote)[![Total Downloads](https://camo.githubusercontent.com/5a7f70f91e9ef136734c39643fc9fcf2eec3f6afe0ef04381e7c83ea7d7e5b66/68747470733a2f2f706f7365722e707567782e6f72672f646179646576656c6f70732f766f74652f646f776e6c6f616473)](https://packagist.org/packages/daydevelops/vote)[![License](https://camo.githubusercontent.com/52093f37dd5abbf43be723e93cab51db2b12a690f1251bef7c00e5ce32b38803/68747470733a2f2f706f7365722e707567782e6f72672f646179646576656c6f70732f766f74652f6c6963656e7365)](https://packagist.org/packages/daydevelops/vote)

This package gives your laravel project the ability to create and manage an upvote/downvote system for user created content. This project was inspired by Reddit karma.

Main Features in this Package
-----------------------------

[](#main-features-in-this-package)

This package will provide you with 2 table migrations which will create a votes table (dd\_votes) and a voter table (dd\_voters).

You will also be given access to two traits:

*Votable* -&gt; Adds upvoting and downvoting functionality to a votable object such as a blog post, comment, photos, or anything else with a user\_id representing an owner.

*CanVote* -&gt; To be applied to your User model. Adds additional functionality to your user which lets them manage their ability to vote and provides a votable score (calculated from votes others have casted on their votable objects).

You can also access the two models Vote and Voter.

A config file *vote.php* will be published to your config directory.

Installation
------------

[](#installation)

Via Composer

```
$ composer require daydevelops/vote
$ php artisan vendor:publish
$ php artisan migrate
```

Usage
-----

[](#usage)

### Apply the Votable Trait

[](#apply-the-votable-trait)

Suppose we have a blog and users can create comments. If we want to allow users to upvote and downvote comments, we simply add the Votable trait.

```
...
use Daydevelops\Vote\Traits\Votable;

class Comment extends Model
{
    use Votable;

    ...

}
```

### Apply the CanVote Trait

[](#apply-the-canvote-trait)

The CanVote trait should be applied to your User model.

```
...
use Daydevelops\Vote\Traits\CanVote;

class User extends Model
{
    use CanVote;

    ...

}
```

### Available Methods/Properties on the Votable Object

[](#available-methodsproperties-on-the-votable-object)

**Authenticated User Casts a Vote**

```
$this->vote($type); // $type should be "up" or "down"

```

**Authenticated User Casts an Upvote**

```
$this->upVote(); // alias of $this->vote('up');

```

**Authenticated User Casts a Downvote**

```
$this->downVote(); // alias of $this->vote('down');

```

**Authenticated User Removes a Vote**

```
$this->unVote();

```

**Has the Authenticated User Voted on this Object?**

```
$this->hasVoted();

```

**Has the Authenticated User Upvoted this Object?**

```
$this->hasUpVoted();

```

**Has the Authenticated User Downvoted this Object?**

```
$this->hasDownVoted();

```

**Get a Collection of all the Votes on this Object**

```
$this->votes(); // hasMany relationship

```

**Get the Total Score of all Votes Casted on this Object**

```
$this->score;

```

### Available Methods/Properties on the CanVote (User) Object

[](#available-methodsproperties-on-the-canvote-user-object)

**Does this User have a Voter Record?**

```
$this->isVoter();

```

**Get the Voter Object for this User**

```
$this->voter; // returns hasOne relationship to Daydevelops\Vote\Models\Voter

```

**Make a Voter Record for this user**

```
$this->makeVoter($change); // optional signed int $change is added to the default voter weight (see config/vote.php) upon creation

```

**Get the Users Score Calculated from Votes Casted by other Users**

```
$this->votable_score;

```

### Available Methods/Properties on the Voter Model

[](#available-methodsproperties-on-the-voter-model)

where `$voter = $user->voter;`:

**Change the Weight of the Voters FUTURE Votes**

```
$voter->addWeight($change); // signed int $change is added to the users current vote weight.

```

**Can the Voter Vote on an Object?**

```
$voter->canVote($votable_item);

```

**Is the Voter Banned from Voting?**

```
$voter->isBanned();

```

**Ban or Unban the Voter**

```
$voter->ban();
$voter->unban();

```

Events
------

[](#events)

**Daydevelops\\Vote\\Events\\ItemUpVoted** -&gt; Fired when a votable object is upvoted

**Daydevelops\\Vote\\Events\\ItemDownVoted** -&gt; Fired when a votable object is udownvoted

**Daydevelops\\Vote\\Events\\VoterWeightChanged** -&gt; Fired when a voters vote weight is updated

Tests
-----

[](#tests)

For further clarification on any of the features of this package, take a look at the tests or reach out to the maintainer of the package.

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Daydevelops](https://github.com/daydevelops)

License
-------

[](#license)

MIT. Please see the [license file](LICENSE) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

2212d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d6afa12ef0994c6abe0de6379bcf5a50c7ded35cac43a235806f9d86a1aa071?d=identicon)[daydevelops](/maintainers/daydevelops)

---

Top Contributors

[![daydevelops](https://avatars.githubusercontent.com/u/38594177?v=4)](https://github.com/daydevelops "daydevelops (6 commits)")

---

Tags

laravelvote

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/daydevelops-vote/health.svg)

```
[![Health](https://phpackages.com/badges/daydevelops-vote/health.svg)](https://phpackages.com/packages/daydevelops-vote)
```

###  Alternatives

[willvincent/laravel-rateable

Allows multiple models to be rated with a fivestar like system.

416452.0k3](/packages/willvincent-laravel-rateable)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
