PHPackages                             ranrinc/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ranrinc/larapoll

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ranrinc/larapoll
================

A Laravel package to create polls

2.6.0(6y ago)012MITPHP

Since Jan 24Pushed 6y agoCompare

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

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

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(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

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 82.4% 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 ~262 days

Total

5

Last Release

2342d ago

Major Versions

1.0 → 2.02017-10-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/1783b7dfe55f81bb20b82895da7dde2cc7e50b1858766f8841386a4f468e00bc?d=identicon)[ranrinc](/maintainers/ranrinc)

---

Top Contributors

[![akiyamaSM](https://avatars.githubusercontent.com/u/12276076?v=4)](https://github.com/akiyamaSM "akiyamaSM (140 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)")[![khofaai](https://avatars.githubusercontent.com/u/12723639?v=4)](https://github.com/khofaai "khofaai (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)")[![wasutz](https://avatars.githubusercontent.com/u/9117486?v=4)](https://github.com/wasutz "wasutz (1 commits)")

---

Tags

phplaravelpollsvotes

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[monicahq/laravel-cloudflare

Add Cloudflare ip addresses to trusted proxies for Laravel.

3372.7M4](/packages/monicahq-laravel-cloudflare)[mediconesystems/livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS

1.2k711.3k8](/packages/mediconesystems-livewire-datatables)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)

PHPackages © 2026

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