PHPackages                             temian/laravelpoll - 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. temian/laravelpoll

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

temian/laravelpoll
==================

A Laravel package to create polls

01PHP

Since Apr 29Pushed 3y agoCompare

[ Source](https://github.com/Temian1/laravelpoll)[ Packagist](https://packagist.org/packages/temian/laravelpoll)[ RSS](/packages/temian-laravelpoll/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)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(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

14

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 82.1% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d5332b731e1d74292dd2514693df159822027cdea967e29ce79206d3e5d97d17?d=identicon)[Kikismedia](/maintainers/Kikismedia)

---

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)")[![nexxai](https://avatars.githubusercontent.com/u/4316564?v=4)](https://github.com/nexxai "nexxai (2 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (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)")[![Temian1](https://avatars.githubusercontent.com/u/39234980?v=4)](https://github.com/Temian1 "Temian1 (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)")

### Embed Badge

![Health badge](/badges/temian-laravelpoll/health.svg)

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

###  Alternatives

[voku/portable-ascii

Portable ASCII library - performance optimized (ascii) string functions for php.

576437.1M171](/packages/voku-portable-ascii)[spatie/laravel-flash

A lightweight package to flash messages

6732.0M17](/packages/spatie-laravel-flash)

PHPackages © 2026

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