src/Common/Console/Seed/DefaultSeed.php
public function execute()
    {
        $oModel = Factory::model(static::CONFIG_MODEL_NAME, static::CONFIG_MODEL_PROVIDER);

        /** @var Locale $oLocale */
        $oLocale        = Factory::service('Locale');
        $oDefaultLocale = $oLocale->getDefautLocale();

        $aFieldsDescribed = $oModel->describeFields();
        $aFields          = [];

        foreach ($aFieldsDescribed as $oField) {
            if (!in_array($oField->key, static::CONFIG_IGNORE_FIELDS)) {
                $aFields[] = $oField;
            }
        }

        for ($i = 0; $i < static::CONFIG_NUM_PER_SEED; $i++) {
            try {
                $aData = $this->generate($aFields);
                if (classUses($oModel, Localised::class)) {
                    if (!$oModel->create($aData, false, $oDefaultLocale)) {
                        throw new NailsException('Failed to create item. ' . $oModel->lastError());
                    }
                } elseif (!$oModel->create($aData)) {
                    throw new NailsException('Failed to create item. ' . $oModel->lastError());
                }
            } catch (\Exception $e) {
                echo "\nSEED ERROR: " . $e->getMessage();
            }
        }
    }
public function execute()
    {
        $oModel = Factory::model(static::CONFIG_MODEL_NAME, static::CONFIG_MODEL_PROVIDER);

        /** @var Locale $oLocale */
        $oLocale        = Factory::service('Locale');
        $oDefaultLocale = $oLocale->getDefautLocale();

        $aFieldsDescribed = $oModel->describeFields();
        $aFields          = [];

        foreach ($aFieldsDescribed as $oField) {
            if (!in_array($oField->key, static::CONFIG_IGNORE_FIELDS)) {
                $aFields[] = $oField;
            }
        }

        for ($i = 0; $i < static::CONFIG_NUM_PER_SEED; $i++) {
            try {
                $aData = $this->generate($aFields);
                if (classUses($oModel, Localised::class)) {
                    if (!$oModel->create($aData, false, $oDefaultLocale)) {
                        throw new NailsException('Failed to create item. ' . $oModel->lastError());
                    }
                } elseif (!$oModel->create($aData)) {
                    throw new NailsException('Failed to create item. ' . $oModel->lastError());
                }
            } catch (\Exception $e) {
                echo "\nSEED ERROR: " . $e->getMessage();
            }
        }
    }
public function execute ( ) { $ oModel = Factory :: model ( static :: CONFIG_MODEL_NAME , static :: CONFIG_MODEL_PROVIDER ) ; /** @var Locale $oLocale */ $ oLocale = Factory :: service ( 'Locale' ) ; $ oDefaultLocale = $ oLocale -> getDefautLocale ( ) ; $ aFieldsDescribed = $ oModel -> describeFields ( ) ; $ aFields = [ ] ; foreach ( $ aFieldsDescribed as $ oField ) { if ( ! in_array ( $ oField -> key , static :: CONFIG_IGNORE_FIELDS ) ) { $ aFields [ ] = $ oField ; } } for ( $ i = 0 ; $ i < static :: CONFIG_NUM_PER_SEED ; $ i ++ ) { try { $ aData = $ this -> generate ( $ aFields ) ; if ( classUses ( $ oModel , Localised :: class ) ) { if ( ! $ oModel -> create ( $ aData , false , $ oDefaultLocale ) ) { throw new NailsException ( 'Failed to create item. ' . $ oModel -> lastError ( ) ) ; } } elseif ( ! $ oModel -> create ( $ aData ) ) { throw new NailsException ( 'Failed to create item. ' . $ oModel -> lastError ( ) ) ; } } catch ( \ Exception $ e ) { echo "\nSEED ERROR: " . $ e -> getMessage ( ) ; } } }
Execute the seed

@return void
Execute the seed