{"id":19943939,"url":"https://github.com/akiyamasm/larapoll","last_synced_at":"2025-04-13T04:59:21.594Z","repository":{"id":43040104,"uuid":"79646855","full_name":"akiyamaSM/larapoll","owner":"akiyamaSM","description":"A Laravel package to manage your polls","archived":false,"fork":false,"pushed_at":"2022-10-07T10:37:59.000Z","size":202,"stargazers_count":259,"open_issues_count":7,"forks_count":60,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-13T04:59:15.175Z","etag":null,"topics":["eloquent","laravel","poll","survey","vote"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akiyamaSM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-21T13:18:44.000Z","updated_at":"2025-03-31T14:13:50.000Z","dependencies_parsed_at":"2022-09-09T17:00:39.100Z","dependency_job_id":null,"html_url":"https://github.com/akiyamaSM/larapoll","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2Flarapoll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2Flarapoll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2Flarapoll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2Flarapoll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akiyamaSM","download_url":"https://codeload.github.com/akiyamaSM/larapoll/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665758,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eloquent","laravel","poll","survey","vote"],"created_at":"2024-11-13T00:18:32.089Z","updated_at":"2025-04-13T04:59:21.574Z","avatar_url":"https://github.com/akiyamaSM.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Larapoll\nA Laravel package to manage your polls\n\n\n## Installation:\nFirst, install the package through Composer. \n\n```bash\ncomposer require inani/larapoll \n```\n\nYou can skip the next two steps\n\nThen include the service provider inside `config/app.php`.\n\n```php\n'providers' =\u003e [\n    ...\n    Inani\\Larapoll\\LarapollServiceProvider::class,\n    ...\n];\n\n\n'aliases' =\u003e [\n        ...\n        'PollWriter' =\u003e Inani\\Larapoll\\PollWriterFacade::class,\n        ...\n];\n```\n\n\nPublish migrations, and migrate\n\n```bash\nphp artisan vendor:publish\nphp artisan migrate\n```\n\n___\n\n## Setup a Model\n\nTo setup a model all you have to do is add (and import) the `Voter` trait.\n\n```php\nuse Inani\\Larapoll\\Traits\\Voter;\nclass User extends Model\n{\n    use Voter;\n    ...\n}\n```\n\n___\n\n## Creating, editing and closing polls\n\n### Create poll\n```php\n// create the question\n$poll = new Poll([\n            'question' =\u003e 'What is the best PHP framework?'\n]); \n\n// attach options and how many options you can vote to\n// more than 1 options will be considered as checkboxes\n$poll-\u003eaddOptions(['Laravel', 'Zend', 'Symfony', 'Cake'])\n                     -\u003emaxSelection() // you can ignore it as well\n                     -\u003egenerate();\n$poll-\u003eisRadio(); // true\n$poll-\u003eisCheckable(); // false\n$poll-\u003eoptionsNumber(); // 4\n```\n### attach and detach options to a poll\n```php\n// to add new elements \n$bool = $poll-\u003eattach([\n            'Yii', 'CodeIgniter'\n]);\n$poll-\u003eoptionsNumber(); // 6\n\n// to remove options(not voted yet)\n$option = $poll-\u003eoptions()-\u003efirst(); // get first option\n$bool = $poll-\u003edetach($option); \n$poll-\u003eoptionsNumber(); // 5\n```\n### Lock a poll\n```php\n$bool = $poll-\u003elock();\n```\n### Unlock a closed poll\n```php\n$bool = $poll-\u003eunLock();\n```\n### Remove a poll\nAll related options and votes will be deleted once the Poll is removed\n```php\n$bool = $poll-\u003eremove();\n```\n## Voting\n\n### Making votes\n```php\n// a voter(user) picks a poll to vote for\n// only ids or array of ids are accepted\n$voter-\u003epoll($poll)-\u003evote($voteFor-\u003egetKey());\n```\n### Result of votes\n```php\n// get results unordered\n$poll-\u003eresults()-\u003egrab();\n// get results in order (desc)\n$poll-\u003eresults()-\u003einOrder();\n```\n\n## CRUD HANDLER\nLaraPoll ships with a UI a system to manage polls, very easy and fast. you need practically nothing to start using it.\n[Please visit the link for the explantation of the interface.](https://medium.com/@InaniT0/create-polls-easily-using-laravel-package-larapoll-d8e520f021f5)\n\n### Set up the admin middleware's name\nA 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\nAdd this line in the .env too\n\n```php\nLARAPOLL_ADMIN_AUTH_MIDDLEWARE = auth\nLARAPOLL_ADMIN_AUTH_GUARD = web\nLARAPOLL_PAGINATION = 10\nLARAPOLL_PREFIX = Larapoll\n```\n\n## FRONT END USE\nWith Larapoll its easy to integrate a poll for users to vote, you only have to specify two things\n- the ID of the poll \n\n```php\n{{ PollWriter::draw(Inani\\Larapoll\\Poll::find(77)) }}\n```\n### Override views\nYou 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.\n\n#### Route of the vote action\n``` php\n{{ route('poll.vote', $id) }}\n```\n\n#### Data passed to result view\n- $question : the question of the poll\n- $options : array of objects holding (name, percent, votes).\n#### Data passed to the poll checkbox/radio\n- $question : the question\n- $options : holding the name and id of the option.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakiyamasm%2Flarapoll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakiyamasm%2Flarapoll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakiyamasm%2Flarapoll/lists"}