All Projects → akiyamaSM → Larapoll

akiyamaSM / Larapoll

Licence: mit
A Laravel package to manage your polls

Projects that are alternatives of or similar to Larapoll

Laravel Love
Add Social Reactions to Laravel Eloquent Models. It lets people express how they feel about the content. Fully customizable Weighted Reaction System & Reaction Type System with Like, Dislike and any other custom emotion types. Do you react?
Stars: ✭ 822 (+334.92%)
Mutual labels:  eloquent, laravel, vote
Sieve
A simple, clean and elegant way to filter Eloquent models.
Stars: ✭ 123 (-34.92%)
Mutual labels:  eloquent, laravel
Guardian
Eloquent Guardian is a simple permissions system for your users. While there are many other packages for permissions, this one solves everything in the most eloquent way.
Stars: ✭ 121 (-35.98%)
Mutual labels:  eloquent, laravel
Laravel Deletable
👾 Gracefully restrict deletion of Laravel Eloquent models
Stars: ✭ 137 (-27.51%)
Mutual labels:  eloquent, laravel
Laravel Cacheable
Rinvex Cacheable is a granular, intuitive, and fluent caching system for eloquent models. Simple, but yet powerful, plug-n-play with no hassle.
Stars: ✭ 107 (-43.39%)
Mutual labels:  eloquent, laravel
Searchable
Search/filter functionality for Laravel's Eloquent models
Stars: ✭ 113 (-40.21%)
Mutual labels:  eloquent, laravel
Eager Load Pivot Relations
Eager load pivot relations for Laravel Eloquent's BelongsToMany relation.
Stars: ✭ 134 (-29.1%)
Mutual labels:  eloquent, laravel
Laravel Likeable
Rate Eloquent models with Likes and Dislikes in Laravel. Development moved to Laravel Love package!
Stars: ✭ 95 (-49.74%)
Mutual labels:  eloquent, laravel
Pinatra
A PHP copy of Sinatra: a DSL for quickly creating web applications in PHP with minimal effort.
Stars: ✭ 151 (-20.11%)
Mutual labels:  eloquent, laravel
Schedule
Schedule is a package that helps tracking schedules for your models. If you have workers in a company, you can set schedules for them and see their availability though the time.
Stars: ✭ 155 (-17.99%)
Mutual labels:  eloquent, laravel
Rating
Laravel Eloquent Rating allows you to assign ratings to any model.
Stars: ✭ 175 (-7.41%)
Mutual labels:  eloquent, laravel
Laravel Settings
Store key value pair in database as settings
Stars: ✭ 107 (-43.39%)
Mutual labels:  eloquent, laravel
Laravel Translatable
Making Eloquent models translatable
Stars: ✭ 1,390 (+635.45%)
Mutual labels:  eloquent, laravel
Laravel Invoicable
Easy invoice creation for Laravel
Stars: ✭ 118 (-37.57%)
Mutual labels:  eloquent, laravel
Sarala
Javascript library to communicate with RESTful API built following JSON API specification. inspired by Laravel’s Eloquent
Stars: ✭ 101 (-46.56%)
Mutual labels:  eloquent, laravel
Querybuilderparser
A simple to use query builder for the jQuery QueryBuilder plugin for use with Laravel.
Stars: ✭ 126 (-33.33%)
Mutual labels:  eloquent, laravel
Eloquent Filter
The Eloquent Filter is a package for filter data of models by the query string. Easy to use and fully dynamic.
Stars: ✭ 175 (-7.41%)
Mutual labels:  eloquent, laravel
Laravel Nullable Fields
Handles saving empty fields as null for Eloquent models
Stars: ✭ 88 (-53.44%)
Mutual labels:  eloquent, laravel
Laravel Prefixed Ids
Friendly prefixed IDs for Laravel models
Stars: ✭ 88 (-53.44%)
Mutual labels:  eloquent, laravel
Laravel Model Expires
A package to assign expiration dates to Eloquent models.
Stars: ✭ 148 (-21.69%)
Mutual labels:  eloquent, laravel

Larapoll

A Laravel package to manage your polls

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

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

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

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

$bool = $poll->lock();

Unlock a closed poll

$bool = $poll->unLock();

Remove a poll

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

$bool = $poll->remove();

Voting

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

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

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.

Set up the admin middleware's 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

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

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('poll.vote', $id) }}

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

  • $question : the question
  • $options : holding the name and id of the option.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].