PHP code example of dozen-software / listcraft

1. Go to this page and download the library: Download dozen-software/listcraft library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dozen-software / listcraft example snippets


    'Dozensoftware\Listcraft\ListcraftServiceProvider'

    'Listcraft' => 'Dozensoftware\Listcraft\Listcraft'

php artisan listcraft:attach {table_name} {position_column_name}
php artisan migrate

class User extends Eloquent
{
    use \Dozensoftware\Listcraft\Listcraft;

    public function __construct(array $attributes = array(), $exists = false) {

        parent::__construct($attributes, $exists);

        $this->initListcraft();
    }
}

class User extends Eloquent
{
    use \Dozensoftware\Listcraft\Listcraft;

    public function __construct(array $attributes = array(), $exists = false) {

        parent::__construct($attributes, $exists);

        $this->initListcraft([
            'scope' => 'answer_to_ltuae = 42'
        ]);
    }
}

class ToDoListItem extends Eloquent
{
    use \Dozensoftware\Listcraft\Listcraft;

    public function __construct(array $attributes = array(), $exists = false) {

        parent::__construct($attributes, $exists);

        $this->initListcraft([
            'scope' => $this->toDoList()
        ]);
    }

    public function toDoList()
    {
        $this->belongsTo('ToDoList');
    }
}

class ToDoListItem extends Eloquent
{
    use \Dozensoftware\Listcraft\Listcraft;

    public function __construct(array $attributes = array(), $exists = false) {

        parent::__construct($attributes, $exists);

        $this->initListcraft([
            'scope' => DB::table($this->getTable())->where('type', '=', 'Not A List of My Favorite Porn Videos')
        ]);
    }
}

$this->setListcraftConfig('scope', 'what_does_the_fox_say = "ring ding ding ding"');