New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

convenia/checklistable

Make any model checklistable with answer per ID
15,610 8
Install
composer require convenia/checklistable
Latest Version:v1.0.2
PHP:>=7
Laravel:5
License:MIT
Last Updated:May 11, 2018
Links: GitHub  ·  Packagist
Maintainer: euventura

checklistable logo

               

Codacy Badge Codacy Badge Build Status GitHub forks Dependencies GitHub Issues Contributions welcome License

Basic Overview

Add checklist in your project associated any model in your project

Install

composer require convenia/checklistable

publish migrations

php artisan vendor:publish --tag="checklistable"

migrate

php artisan migrate

Usage

add a trait
namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use Convenia\Checklistable\Traits\ChecklistableTrait;

class ModelClass extends Model
{
    use ChecklistableTrait;    
Checklist Methods
checklist()
// Return ChecklistService Object
ModelClass::checklist($type, $ownerId);  
checklist()->get()
// Return Checklist Model, if not existe will create it
ModelClass::checklist($type, $ownerId)->get();  
Question Methods
checklist()->questions()
// 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 ?'
    ]);  
Answer Methods
checklist()->answer()
// 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)

License

Checklistable is open-sourced software licensed under the MIT license

Related Packages

wisoot/entity

Base Entity

3,658 1
rtablada/standard-model

A slick little way to work with data in an "Eloquent" fashion

41 2
jenssegers/model

An Laravel eloquent-like model class, for Laravel and other frameworks

4,742,551 395
czim/laravel-nestedupdater

Eloquent model updater for nested relations data for Laravel.

54,158 19

Version History

Version Released PHP Laravel License
v1.0.2 >=7 ~5.2|~5.3|~5.4|~5.5 MIT
v1.0.1 >=7 ~5.2|~5.3|~5.4|~5.5 MIT
v1.0.0 >=7 ~5.2|~5.3|~5.4|~5.5 MIT
v0.0.1 >=7 ~5.2|~5.3|~5.4|~5.5 MIT