PHPackages                             inani/larapoll - 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. [Database &amp; ORM](/categories/database)
4. /
5. inani/larapoll

ActiveLibrary[Database &amp; ORM](/categories/database)

inani/larapoll
==============

A Laravel package to create polls

3.1(4y ago)25517.7k↓50%59[6 issues](https://github.com/akiyamaSM/larapoll/issues)1MITPHPCI failing

Since Jan 24Pushed 3y ago14 watchersCompare

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

READMEChangelog (10)Dependencies (3)Versions (20)Used By (1)

Larapoll
========

[](#larapoll)

A Laravel package to manage your polls

Installation:
-------------

[](#installation)

First, install the package through Composer.

```
composer require inani/larapoll
```

You can skip the next two steps

Then include the service provider inside `config/app.php`.

```
'providers' => [
    ...
    Inani\Larapoll\LarapollServiceProvider::class,
    ...
];

'aliases' => [
        ...
        'PollWriter' => Inani\Larapoll\PollWriterFacade::class,
        ...
];
```

Publish migrations, and migrate

```
php artisan vendor:publish
php artisan migrate
```

---

Setup a Model
-------------

[](#setup-a-model)

To setup a model all you have to do is add (and import) the `Voter` trait.

```
use Inani\Larapoll\Traits\Voter;
class User extends Model
{
    use Voter;
    ...
}
```

---

Creating, editing and closing polls
-----------------------------------

[](#creating-editing-and-closing-polls)

### Create poll

[](#create-poll)

```
// create the question
$poll = new Poll([
            'question' => 'What is the best PHP framework?'
]);

// attach options and how many options you can vote to
// more than 1 options will be considered as checkboxes
$poll->addOptions(['Laravel', 'Zend', 'Symfony', 'Cake'])
                     ->maxSelection() // you can ignore it as well
                     ->generate();
$poll->isRadio(); // true
$poll->isCheckable(); // false
$poll->optionsNumber(); // 4
```

### attach and detach options to a poll

[](#attach-and-detach-options-to-a-poll)

```
// to add new elements
$bool = $poll->attach([
            'Yii', 'CodeIgniter'
]);
$poll->optionsNumber(); // 6

// to remove options(not voted yet)
$option = $poll->options()->first(); // get first option
$bool = $poll->detach($option);
$poll->optionsNumber(); // 5
```

### Lock a poll

[](#lock-a-poll)

```
$bool = $poll->lock();
```

### Unlock a closed poll

[](#unlock-a-closed-poll)

```
$bool = $poll->unLock();
```

### Remove a poll

[](#remove-a-poll)

All related options and votes will be deleted once the Poll is removed

```
$bool = $poll->remove();
```

Voting
------

[](#voting)

### Making votes

[](#making-votes)

```
// a voter(user) picks a poll to vote for
// only ids or array of ids are accepted
$voter->poll($poll)->vote($voteFor->getKey());
```

### Result of votes

[](#result-of-votes)

```
// get results unordered
$poll->results()->grab();
// get results in order (desc)
$poll->results()->inOrder();
```

CRUD HANDLER
------------

[](#crud-handler)

LaraPoll ships with a UI a system to manage polls, very easy and fast. you need practically nothing to start using it. [Please visit the link for the explantation of the interface.](https://medium.com/@InaniT0/create-polls-easily-using-laravel-package-larapoll-d8e520f021f5)

### Set up the admin middleware's name

[](#set-up-the-admin-middlewares-name)

A larapoll\_config.php file will be added where you can put the name of the middleware used to protect the access and other things like pagination and prefix to protect your routes Add this line in the .env too

```
LARAPOLL_ADMIN_AUTH_MIDDLEWARE = auth
LARAPOLL_ADMIN_AUTH_GUARD = web
LARAPOLL_PAGINATION = 10
LARAPOLL_PREFIX = Larapoll
```

FRONT END USE
-------------

[](#front-end-use)

With Larapoll its easy to integrate a poll for users to vote, you only have to specify two things

- the ID of the poll

```
{{ PollWriter::draw(Inani\Larapoll\Poll::find(77)) }}
```

### Override views

[](#override-views)

You can override the views related to the results page and both pages checkbox/radio via the same larapoll\_config.php file in the config folder.

#### Route of the vote action

[](#route-of-the-vote-action)

```
{{ route('poll.vote', $id) }}
```

#### Data passed to result view

[](#data-passed-to-result-view)

- $question : the question of the poll
- $options : array of objects holding (name, percent, votes).

#### Data passed to the poll checkbox/radio

[](#data-passed-to-the-poll-checkboxradio)

- $question : the question
- $options : holding the name and id of the option.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 82.6% 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 ~159 days

Recently: every ~97 days

Total

11

Last Release

1808d ago

Major Versions

1.0 → 2.02017-10-06

2.9.5 → 3.02020-12-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/0fbeb774293770efe72dfe486b323e999e6d65d0df0db9052a1e5b76d9711efe?d=identicon)[akiyamaSM](/maintainers/akiyamaSM)

---

Top Contributors

[![akiyamaSM](https://avatars.githubusercontent.com/u/12276076?v=4)](https://github.com/akiyamaSM "akiyamaSM (161 commits)")[![obiefy](https://avatars.githubusercontent.com/u/16496932?v=4)](https://github.com/obiefy "obiefy (22 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (2 commits)")[![nexxai](https://avatars.githubusercontent.com/u/4316564?v=4)](https://github.com/nexxai "nexxai (2 commits)")[![finallyRaunak](https://avatars.githubusercontent.com/u/22704179?v=4)](https://github.com/finallyRaunak "finallyRaunak (1 commits)")[![P-Shakibafar](https://avatars.githubusercontent.com/u/25016184?v=4)](https://github.com/P-Shakibafar "P-Shakibafar (1 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (1 commits)")[![TrueMoein](https://avatars.githubusercontent.com/u/7044050?v=4)](https://github.com/TrueMoein "TrueMoein (1 commits)")[![vesper8](https://avatars.githubusercontent.com/u/816028?v=4)](https://github.com/vesper8 "vesper8 (1 commits)")[![ivenspontes](https://avatars.githubusercontent.com/u/2898158?v=4)](https://github.com/ivenspontes "ivenspontes (1 commits)")[![wasutz](https://avatars.githubusercontent.com/u/9117486?v=4)](https://github.com/wasutz "wasutz (1 commits)")[![khofaai](https://avatars.githubusercontent.com/u/12723639?v=4)](https://github.com/khofaai "khofaai (1 commits)")

---

Tags

eloquentlaravelpollsurveyvotephplaravelpollsvotes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/inani-larapoll/health.svg)

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

###  Alternatives

[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2031.2M2](/packages/glushkovds-phpclickhouse-laravel)[io238/laravel-iso-countries

Ready-to-use Laravel models and relations for country (ISO 3166), language (ISO 639-1), and currency (ISO 4217) information with multi-language support.

5462.3k](/packages/io238-laravel-iso-countries)[sebastiaanluca/laravel-boolean-dates

Automatically convert Eloquent model boolean attributes to dates (and back).

40111.7k1](/packages/sebastiaanluca-laravel-boolean-dates)[matchory/elasticsearch

The missing elasticsearch ORM for Laravel!

3059.0k](/packages/matchory-elasticsearch)[crcms/repository

Detached model and controller warehouse data provider

674.4k3](/packages/crcms-repository)

PHPackages © 2026

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