library/Garp/Cli/Command/Models.php
public function insert($args) {
        if (empty($args)) {
            Garp_Cli::errorOut('Please provide a model');
            return false;
        }

        $className = "Model_{$args[0]}";
        $model = new $className();
        $fields = $model->getConfiguration('fields');
        $fields = array_filter($fields, not(propertyEquals('name', 'id')));

        $mode = $this->_getInsertionMode();
        if ($mode === 'g') {
            $newData = $this->_createGibberish($fields);
        } else {
            $newData = array_reduce(
                $fields,
                function ($acc, $cur) {
                    $acc[$cur['name']] = Garp_Cli::prompt($cur['name']) ?: null;
                    return $acc;
                },
                array()
            );
        }

        $id = $model->insert($newData);
        Garp_Cli::lineOut("Record created: #{$id}");
        return true;
    }
public function insert($args) {
        if (empty($args)) {
            Garp_Cli::errorOut('Please provide a model');
            return false;
        }

        $className = "Model_{$args[0]}";
        $model = new $className();
        $fields = $model->getConfiguration('fields');
        $fields = array_filter($fields, not(propertyEquals('name', 'id')));

        $mode = $this->_getInsertionMode();
        if ($mode === 'g') {
            $newData = $this->_createGibberish($fields);
        } else {
            $newData = array_reduce(
                $fields,
                function ($acc, $cur) {
                    $acc[$cur['name']] = Garp_Cli::prompt($cur['name']) ?: null;
                    return $acc;
                },
                array()
            );
        }

        $id = $model->insert($newData);
        Garp_Cli::lineOut("Record created: #{$id}");
        return true;
    }
public function insert ( $ args ) { if ( empty ( $ args ) ) { Garp_Cli :: errorOut ( 'Please provide a model' ) ; return false ; } $ className = "Model_{$args[0]}" ; $ model = new $ className ( ) ; $ fields = $ model -> getConfiguration ( 'fields' ) ; $ fields = array_filter ( $ fields , not ( propertyEquals ( 'name' , 'id' ) ) ) ; $ mode = $ this -> _getInsertionMode ( ) ; if ( $ mode === 'g' ) { $ newData = $ this -> _createGibberish ( $ fields ) ; } else { $ newData = array_reduce ( $ fields , function ( $ acc , $ cur ) { $ acc [ $ cur [ 'name' ] ] = Garp_Cli :: prompt ( $ cur [ 'name' ] ) ? : null ; return $ acc ; } , array ( ) ) ; } $ id = $ model -> insert ( $ newData ) ; Garp_Cli :: lineOut ( "Record created: #{$id}" ) ; return true ; }
Interactively insert a new record

@param array $args
@return bool
Interactively insert a new record