protected function getGuessedColumnFormatters($model, $seeding, $populateForeignKeys = false)
    {
        $this->setColumns($model);

        $formatters = [];

        $nameGuesser = new Name($this->generator);
        $columnTypeGuesser = new ColumnTypeGuesser($this->generator);

        foreach ($this->columns as $columnName => $column) {
            // Skips autoincremented primary keys.
            if ($model instanceof Model && $columnName === $model->getKeyName() && $column->getAutoincrement()) {
                continue;
            }

            // And deleted_at.
            if (
                method_exists($model, 'getDeletedAtColumn')
                && $columnName === $model->getDeletedAtColumn()
            ) {
                continue;
            }

            if (
                !$seeding && $model instanceof Model &&
                ($columnName === $model->getCreatedAtColumn() || $columnName === $model->getUpdatedAtColumn())
            ) {
                continue;
            }

            // Guesses based on the column's name, and if unable to,
            // guesses based on the column's type.
            $formatter = $nameGuesser->guessFormat($columnName, $column->getLength())
                ?: $columnTypeGuesser->guessFormat($column, $model->getTable());

            if (!$formatter) {
                continue;
            }

            if ($column->getNotnull() || !$seeding) {
                $formatters[$columnName] = $formatter;
            } else {
                $formatters[$columnName] = function () use ($formatter) {
                    return rand(0, 1) ? $formatter() : null;
                };
            }
        }

        return $populateForeignKeys ? $this->populateForeignKeys($formatters, $seeding) : $formatters;
    }
protected function getGuessedColumnFormatters($model, $seeding, $populateForeignKeys = false)
    {
        $this->setColumns($model);

        $formatters = [];

        $nameGuesser = new Name($this->generator);
        $columnTypeGuesser = new ColumnTypeGuesser($this->generator);

        foreach ($this->columns as $columnName => $column) {
            // Skips autoincremented primary keys.
            if ($model instanceof Model && $columnName === $model->getKeyName() && $column->getAutoincrement()) {
                continue;
            }

            // And deleted_at.
            if (
                method_exists($model, 'getDeletedAtColumn')
                && $columnName === $model->getDeletedAtColumn()
            ) {
                continue;
            }

            if (
                !$seeding && $model instanceof Model &&
                ($columnName === $model->getCreatedAtColumn() || $columnName === $model->getUpdatedAtColumn())
            ) {
                continue;
            }

            // Guesses based on the column's name, and if unable to,
            // guesses based on the column's type.
            $formatter = $nameGuesser->guessFormat($columnName, $column->getLength())
                ?: $columnTypeGuesser->guessFormat($column, $model->getTable());

            if (!$formatter) {
                continue;
            }

            if ($column->getNotnull() || !$seeding) {
                $formatters[$columnName] = $formatter;
            } else {
                $formatters[$columnName] = function () use ($formatter) {
                    return rand(0, 1) ? $formatter() : null;
                };
            }
        }

        return $populateForeignKeys ? $this->populateForeignKeys($formatters, $seeding) : $formatters;
    }
protected function getGuessedColumnFormatters ( $ model , $ seeding , $ populateForeignKeys = false ) { $ this -> setColumns ( $ model ) ; $ formatters = [ ] ; $ nameGuesser = new Name ( $ this -> generator ) ; $ columnTypeGuesser = new ColumnTypeGuesser ( $ this -> generator ) ; foreach ( $ this -> columns as $ columnName => $ column ) { // Skips autoincremented primary keys. if ( $ model instanceof Model && $ columnName === $ model -> getKeyName ( ) && $ column -> getAutoincrement ( ) ) { continue ; } // And deleted_at. if ( method_exists ( $ model , 'getDeletedAtColumn' ) && $ columnName === $ model -> getDeletedAtColumn ( ) ) { continue ; } if ( ! $ seeding && $ model instanceof Model && ( $ columnName === $ model -> getCreatedAtColumn ( ) || $ columnName === $ model -> getUpdatedAtColumn ( ) ) ) { continue ; } // Guesses based on the column's name, and if unable to, // guesses based on the column's type. $ formatter = $ nameGuesser -> guessFormat ( $ columnName , $ column -> getLength ( ) ) ? : $ columnTypeGuesser -> guessFormat ( $ column , $ model -> getTable ( ) ) ; if ( ! $ formatter ) { continue ; } if ( $ column -> getNotnull ( ) || ! $ seeding ) { $ formatters [ $ columnName ] = $ formatter ; } else { $ formatters [ $ columnName ] = function ( ) use ( $ formatter ) { return rand ( 0 , 1 ) ? $ formatter ( ) : null ; } ; } } return $ populateForeignKeys ? $ this -> populateForeignKeys ( $ formatters , $ seeding ) : $ formatters ; }
Guess the column formatters based on the columns' names or types or on whether they are a foreign key.

@param  Model|BelongsToMany $model
@param  bool                $seeding
@param  bool                $populateForeignKeys
@return array
Guess the column formatters based on the columns names or types or on whether they are a foreign key .