src/AbstractServiceProvider.php
final protected function runDatabaseMigrationsAndSeeders()
    {
        // Ask to migrate the database,
        // if we've copied any migration files to the application.
        if (!empty($this->migrations) && $this->getCommand()->confirm('Do you wish to migrate your database?', true)) {
            try {
                $this->getCommand()->call('migrate');
            } catch (Exception $e) {
                $this->getCommand()->error(sprintf('Could not migrate your database. Reason: %s', $e->getMessage()));
            }
        }

        // Before we ask user to seed the database
        // we need to have look in the $seeders array
        // to remove folders from the array
        $seeders = [];
        foreach ($this->seeders as $seeder) {
            if (is_dir(base_path($seeder))) {
                continue;
            }
            $seeders[] = $seeder;
        }

        // Ask to seed the database,
        // if we've copied any migration files to the application.
        if (!empty($seeders) && $this->getCommand()->confirm('Do you wish to seed your database?', true)) {
            // Load seeders directory so new seeders are available
            load_directory($this->getInstaller()->getBasePath('database/seeds/'));

            // Run package seeders
            foreach ($seeders as $seeder) {
                try {
                    $seederFilename = substr($seeder, strrpos($seeder, '/') + 1);
                    $this->getCommand()->call('db:seed', [
                        '--class' => substr($seederFilename, 0, strrpos($seederFilename, '.')),
                    ]);
                } catch (Exception $e) {
                    $this->getCommand()->error(sprintf('Could not seed database. Reason: %s', $e->getMessage()));
                }
            }
        }
    }
final protected function runDatabaseMigrationsAndSeeders()
    {
        // Ask to migrate the database,
        // if we've copied any migration files to the application.
        if (!empty($this->migrations) && $this->getCommand()->confirm('Do you wish to migrate your database?', true)) {
            try {
                $this->getCommand()->call('migrate');
            } catch (Exception $e) {
                $this->getCommand()->error(sprintf('Could not migrate your database. Reason: %s', $e->getMessage()));
            }
        }

        // Before we ask user to seed the database
        // we need to have look in the $seeders array
        // to remove folders from the array
        $seeders = [];
        foreach ($this->seeders as $seeder) {
            if (is_dir(base_path($seeder))) {
                continue;
            }
            $seeders[] = $seeder;
        }

        // Ask to seed the database,
        // if we've copied any migration files to the application.
        if (!empty($seeders) && $this->getCommand()->confirm('Do you wish to seed your database?', true)) {
            // Load seeders directory so new seeders are available
            load_directory($this->getInstaller()->getBasePath('database/seeds/'));

            // Run package seeders
            foreach ($seeders as $seeder) {
                try {
                    $seederFilename = substr($seeder, strrpos($seeder, '/') + 1);
                    $this->getCommand()->call('db:seed', [
                        '--class' => substr($seederFilename, 0, strrpos($seederFilename, '.')),
                    ]);
                } catch (Exception $e) {
                    $this->getCommand()->error(sprintf('Could not seed database. Reason: %s', $e->getMessage()));
                }
            }
        }
    }
final protected function runDatabaseMigrationsAndSeeders ( ) { // Ask to migrate the database, // if we've copied any migration files to the application. if ( ! empty ( $ this -> migrations ) && $ this -> getCommand ( ) -> confirm ( 'Do you wish to migrate your database?' , true ) ) { try { $ this -> getCommand ( ) -> call ( 'migrate' ) ; } catch ( Exception $ e ) { $ this -> getCommand ( ) -> error ( sprintf ( 'Could not migrate your database. Reason: %s' , $ e -> getMessage ( ) ) ) ; } } // Before we ask user to seed the database // we need to have look in the $seeders array // to remove folders from the array $ seeders = [ ] ; foreach ( $ this -> seeders as $ seeder ) { if ( is_dir ( base_path ( $ seeder ) ) ) { continue ; } $ seeders [ ] = $ seeder ; } // Ask to seed the database, // if we've copied any migration files to the application. if ( ! empty ( $ seeders ) && $ this -> getCommand ( ) -> confirm ( 'Do you wish to seed your database?' , true ) ) { // Load seeders directory so new seeders are available load_directory ( $ this -> getInstaller ( ) -> getBasePath ( 'database/seeds/' ) ) ; // Run package seeders foreach ( $ seeders as $ seeder ) { try { $ seederFilename = substr ( $ seeder , strrpos ( $ seeder , '/' ) + 1 ) ; $ this -> getCommand ( ) -> call ( 'db:seed' , [ '--class' => substr ( $ seederFilename , 0 , strrpos ( $ seederFilename , '.' ) ) , ] ) ; } catch ( Exception $ e ) { $ this -> getCommand ( ) -> error ( sprintf ( 'Could not seed database. Reason: %s' , $ e -> getMessage ( ) ) ) ; } } } }
Run database migrations and seeders.

@author Morten Rugaard <moru@nodes.dk>

@return void
Run database migrations and seeders .