https://github.com/convenia/checklistable
Make any model checklistable with answer associated by model_id
https://github.com/convenia/checklistable
checklist checklistable codacy-badge hacktober hacktoberfest laravel laravel5 laravel5-package php7
Last synced: 23 days ago
JSON representation
Make any model checklistable with answer associated by model_id
- Host: GitHub
- URL: https://github.com/convenia/checklistable
- Owner: convenia
- License: mit
- Created: 2017-06-02T18:23:48.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-11T18:04:30.000Z (almost 7 years ago)
- Last Synced: 2025-03-28T22:11:16.286Z (about 1 month ago)
- Topics: checklist, checklistable, codacy-badge, hacktober, hacktoberfest, laravel, laravel5, laravel5-package, php7
- Language: PHP
- Homepage:
- Size: 813 KB
- Stars: 7
- Watchers: 7
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://www.codacy.com/app/Convenia/checklistable_2?utm_source=github.com&utm_medium=referral&utm_content=convenia/checklistable&utm_campaign=Badge_Grade)
[](https://www.codacy.com/app/Convenia/checklistable_2?utm_source=github.com&utm_medium=referral&utm_content=convenia/checklistable&utm_campaign=Badge_Coverage)
[](https://travis-ci.org/convenia/checklistable)
[](https://github.com/convenia/checklistable/network)

[](https://github.com/convenia/checklistable/issues)

[](https://opensource.org/licenses/MIT)## Basic Overview
Add checklist in your project associated any model in your project
## Install
```bash
composer require convenia/checklistable
```### publish migrations
```bash
php artisan vendor:publish --tag="checklistable"
```### migrate
```bash
php artisan migrate
```
## Usage
#### add a trait
```php
namespace App\Model;use Illuminate\Database\Eloquent\Model;
use Convenia\Checklistable\Traits\ChecklistableTrait;class ModelClass extends Model
{
use ChecklistableTrait;
```#### Checklist Methods
##### checklist()
```php
// Return ChecklistService Object
ModelClass::checklist($type, $ownerId);
```##### checklist()->get()
```php
// Return Checklist Model, if not existe will create it
ModelClass::checklist($type, $ownerId)->get();
```#### Question Methods
##### checklist()->questions()
```php
// Return QuestionService Object
ModelClass::checklist($type, $ownerId)
->questions();
```##### checklist()->questions()->get()
```php
// Return Collection of questions
ModelClass::checklist($type, $ownerId)
->questions()
->get();
```##### checklist()->questions()->fill()
```php
// add and return question in lot (only if empty)
ModelClass::checklist($type, $ownerId)
->questions()
->fill([]);
```##### checklist()->questions()->delete()
```php
// delete one question
ModelClass::checklist($type, $ownerId)
->questions()
->delete($questionId);
```##### checklist()->questions()->add()
```php
// add one question an d return all
ModelClass::checklist($type, $ownerId)
->questions()
->add([
'question' => 'What does Marcellus wallace looks like ?'
]);
```#### Answer Methods
##### checklist()->answer()
```php
// Return QuestionService Object
ModelClass::checklist($type, $ownerId)
->answer();
```##### checklist()->answer()->get()
```php
// retrive all answers about checklistable, if do not have, fill it
ModelClass::checklist($type, $ownerId)
->answer()
->get($checklistableId);
```##### checklist()->answer()->start()
```php
// fill the answers with the questions
ModelClass::checklist($type, $ownerId)
->answer()
->start($checklistableId);
```##### checklist()->answer()->answer()
```php
// change answer response
ModelClass::checklist($type, $ownerId)
->answer()
->start($checklistableId, $answerId, $answer = true)
```## License
Checklistable is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)