Larapoll 2.5 : Create Polls easily in Laravel

INANI El Houssain
3 min readOct 6, 2017

--

Voting

Being able to create system to handle polls and voting is what many people ask, and specifically if you are using a Framework, unless you pay for it you’ll get nothing.

That’s why I decided to implement that kind of scripts, in the way of a Package(checkout the link down).

Notes

Before to start here are some rules that I assumed before creating the package :

1 — A pull should have at least two options.

2 — If its a poll with many choices to select, its not possible to check all of them.

3 — You can not edit name of options(to not cheat on the results).

4 — You can not remove a voted option.

Creating Polls

Creating polls is one of the easiest things you may do, you only have to provide the question and the two options at least.

[NEW FEATURE] you can now allow guests to vote too, you just need to select the checkbox, easy isn’t it?

You can set start and end dates of the poll.

Sorry Messi fans, but Cristiano is the best

Modify the poll

1- Edit basic information

After that you can add more options and after that if you have many options you can remove the ones you want.

You can update the following options.

Edit page

2- Add and remove options

Add new options
Remove options

So basically you can :

  • lock/unlock the poll.
  • Edit the number of checkable elements.
  • Delete the poll.

Integrate the poll in the view

Larapoll provides you a very easy way to integrate the poll in the views, you only have to provide the id of the poll.

Make sure to add the Voter trait in the model of User, not required if the voters are guests.

and its shown like that depending on the type of the poll and of course if the Bootstrap is used.

One option select

Show result

In case the poll is finished or the user/guest has voted you will be able to see the result of the voting.

Results of the voting

Override views

The good news is that you will be able to make your own views for the poll(checkbox or radio) and the results.

Configs

Please check the related views of the core for the data that you will have by default.

Repository of Larapoll

Actually the package still have many things to improve in, I Hope that it will be helpful for one of you. Its always nice for me to receive your comments/stars on the repo.

https://github.com/akiyamaSM/larapoll

--

--