src/Common/Console/Command/Make/Database/Seed.php
private function createSeeder(): void
    {
        $aFields  = $this->getArguments();
        $aCreated = [];

        try {

            $aModels = array_filter(explode(',', $aFields['MODEL_NAME']));
            sort($aModels);

            foreach ($aModels as $sModel) {

                $aFields['MODEL_NAME'] = $sModel;
                $this->oOutput->write('Creating seeder <comment>' . $sModel . '</comment>... ');

                //  Validate model exists by attempting to load it
                if (!stringToBoolean($this->oInput->getOption('skip-check'))) {
                    Factory::model($sModel, $aFields['MODEL_PROVIDER']);
                }

                //  Check for existing seeder
                $sPath = static::SEEDER_PATH . $sModel . '.php';
                if (file_exists($sPath)) {
                    throw new SeederExistsException(
                        'Seeder "' . $sModel . '" exists already at path "' . $sPath . '"'
                    );
                }

                $this->createFile($sPath, $this->getResource('template/seeder.php', $aFields));
                $aCreated[] = $sPath;
                $this->oOutput->writeln('<info>done!</info>');
            }

        } catch (\Exception $e) {
            $this->oOutput->writeln('<error>failed!</error>');
            //  Clean up created seeders
            if (!empty($aCreated)) {
                $this->oOutput->writeln('<error>Cleaning up - removing newly created files</error>');
                foreach ($aCreated as $sPath) {
                    @unlink($sPath);
                }
            }
            throw $e;
        }
    }
private function createSeeder(): void
    {
        $aFields  = $this->getArguments();
        $aCreated = [];

        try {

            $aModels = array_filter(explode(',', $aFields['MODEL_NAME']));
            sort($aModels);

            foreach ($aModels as $sModel) {

                $aFields['MODEL_NAME'] = $sModel;
                $this->oOutput->write('Creating seeder <comment>' . $sModel . '</comment>... ');

                //  Validate model exists by attempting to load it
                if (!stringToBoolean($this->oInput->getOption('skip-check'))) {
                    Factory::model($sModel, $aFields['MODEL_PROVIDER']);
                }

                //  Check for existing seeder
                $sPath = static::SEEDER_PATH . $sModel . '.php';
                if (file_exists($sPath)) {
                    throw new SeederExistsException(
                        'Seeder "' . $sModel . '" exists already at path "' . $sPath . '"'
                    );
                }

                $this->createFile($sPath, $this->getResource('template/seeder.php', $aFields));
                $aCreated[] = $sPath;
                $this->oOutput->writeln('<info>done!</info>');
            }

        } catch (\Exception $e) {
            $this->oOutput->writeln('<error>failed!</error>');
            //  Clean up created seeders
            if (!empty($aCreated)) {
                $this->oOutput->writeln('<error>Cleaning up - removing newly created files</error>');
                foreach ($aCreated as $sPath) {
                    @unlink($sPath);
                }
            }
            throw $e;
        }
    }
private function createSeeder ( ) : void { $ aFields = $ this -> getArguments ( ) ; $ aCreated = [ ] ; try { $ aModels = array_filter ( explode ( ',' , $ aFields [ 'MODEL_NAME' ] ) ) ; sort ( $ aModels ) ; foreach ( $ aModels as $ sModel ) { $ aFields [ 'MODEL_NAME' ] = $ sModel ; $ this -> oOutput -> write ( 'Creating seeder <comment>' . $ sModel . '</comment>... ' ) ; //  Validate model exists by attempting to load it if ( ! stringToBoolean ( $ this -> oInput -> getOption ( 'skip-check' ) ) ) { Factory :: model ( $ sModel , $ aFields [ 'MODEL_PROVIDER' ] ) ; } //  Check for existing seeder $ sPath = static :: SEEDER_PATH . $ sModel . '.php' ; if ( file_exists ( $ sPath ) ) { throw new SeederExistsException ( 'Seeder "' . $ sModel . '" exists already at path "' . $ sPath . '"' ) ; } $ this -> createFile ( $ sPath , $ this -> getResource ( 'template/seeder.php' , $ aFields ) ) ; $ aCreated [ ] = $ sPath ; $ this -> oOutput -> writeln ( '<info>done!</info>' ) ; } } catch ( \ Exception $ e ) { $ this -> oOutput -> writeln ( '<error>failed!</error>' ) ; //  Clean up created seeders if ( ! empty ( $ aCreated ) ) { $ this -> oOutput -> writeln ( '<error>Cleaning up - removing newly created files</error>' ) ; foreach ( $ aCreated as $ sPath ) { @ unlink ( $ sPath ) ; } } throw $ e ; } }
Create the Seeder

@throws \Exception
@return void
Create the Seeder