Polls package for Laravel
Install
composer require orangeshadow/polls:dev-master
, (*1)
then copy config, migration and lang, (*2)
php artisan vendor:publish OrangeShadow\\Polls\\SeriviceProvider
, (*3)
run migration, (*4)
php artisan migrate
, (*5)
Config
polls.php, (*6)
routing
- enable or disable routing, (*7)
admin_route_prefix
- prefix for manage polls API route, (*8)
admin_route_middleware
- array middleware for manage polls route, (*9)
public_route_prefix
- prefix for public API route, (*10)
public_route_middleware
- array for manage polls route, (*11)
paginate
- count items returned from api, (*12)
Objects
Routes
admin route:, (*13)
Poll API, (*14)
GET: /admin/poll - Get poll list
POST: /admin/poll - Store Poll
GET: /admin/poll/{poll} - Show poll
PUT: /admin/poll/{poll} - Update poll
DELETE: /admin/poll/{poll} - Remove poll
POST: /admin/poll/{poll}/close - Close Poll
Option API, (*15)
GET: /admin/option - Get option list
POST: /admin/option - Store Option
GET: /admin/option/{option} - Show option
PUT: /admin/option/{option} - Update option
DELETE: /admin/option/{option} Remove option
public route for get poll with options (and result if user did voted), (*16)
Poll API, (*17)
POST: poll/{poll}
public route for voting (only for auth user), (*18)
Poll API, (*19)
POST: poll/{poll}/vote
FORM-DATA: {
options: array
}
Facade PollProxy
$pollProxy = app('PollPropxy',['poll'=>$poll])
Save Vote:, (*20)
$pollProxy->voting($user_id,$options);
Get Result Array:, (*21)
$pollProxy->getResult();