, (*1)
Poll Package for Laravel 5.5
Installation
Run composer require 'abstracteverything/poll', (*2)
OR add:, (*3)
{
"require": {
"abstracteverything/poll": "dev-master"
}
}
to your composer.json file and run composer update., (*4)
Setup
Add AbstractEverything\Poll\PollServiceProvider to your providers array in config/app.php., (*5)
Optionally register the following two facades in config/app.php:, (*6)
'Poll' => AbstractEverything\Poll\Facades\Poll::class,
'Vote' => AbstractEverything\Poll\Facades\Vote::class,
Publishing assets
To publish package assets run: php artisan vendor:publish and choose AbstractEverything\Poll\PollServiceProvider this will publish the following files:, (*7)
- Views to:
resources/vendor/abstracteverything/poll
- Config to:
config/poll.php
- Migrations to
database/migrations
Run the database migrations by running php artisan migrate, (*8)
Setting up the poll user
The user class needs to implement the AbstractEverything\Poll\Extras\PollUserInterface interface and use the AbstractEverything\Poll\Extras\PollUser trait., (*9)
Overriding default routes
The package ships with a default set of routes:, (*10)
-
/polls - polls.index (GET)
-
/polls - polls.store (POST)
-
/polls/create - polls.create (GET)
-
/polls/{poll} - polls.show (GET)
-
/polls/{poll} - polls.destroy (GET)
-
/votes - votes.store (POST)
You can override these by redefining a route with the same name:, (*11)
Route::get('custom_create_page', [
'as' => 'polls.create',
'uses' => '\AbstractEverything\Poll\Http\Controllers\PollController@create',
]);
Middleware configuration
Routes for creating, destroying polls can be protected by middleware. In config/poll.php you can set which middleware should be used., (*12)
Configuration
Other configuration options are avaliable in config/poll.php., (*13)