A Laravel package to create your polls

0.0.1 2018-04-02 20:57 UTC

This package is auto-updated.

Last update: 2024-11-06 09:31:56 UTC


README

Install

composer require orangeshadow/polls:dev-master

then copy config, migration and lang

php artisan vendor:publish OrangeShadow\\Polls\\SeriviceProvider

run migration

php artisan migrate

Config

polls.php

routing - enable or disable routing

admin_route_prefix - prefix for manage polls API route

admin_route_middleware - array middleware for manage polls route

public_route_prefix - prefix for public API route

public_route_middleware - array for manage polls route

paginate - count items returned from api

Objects

Routes

admin route:

Poll API

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

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)

Poll API

POST: poll/{poll}

public route for voting (only for auth user)

Poll API

POST: poll/{poll}/vote
FORM-DATA: {
    options: array 
}

Facade PollProxy

$pollProxy = app('PollPropxy',['poll'=>$poll])

Save Vote:

$pollProxy->voting($user_id,$options);

Get Result Array:

$pollProxy->getResult();