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