Flarum\Extension\Extension::hasMigrations PHP Method

hasMigrations() public method

Tests whether the extension has migrations.
public hasMigrations ( ) : boolean
return boolean
    public function hasMigrations()
    {
        return realpath($this->path . '/migrations/') !== false;
    }

Usage Example

 /**
  * Runs the database migrations for the extension.
  *
  * @param Extension $extension
  * @param bool|true $up
  */
 public function migrate(Extension $extension, $up = true)
 {
     if ($extension->hasMigrations()) {
         $migrationDir = $extension->getPath() . '/migrations';
         $this->app->bind('Illuminate\\Database\\Schema\\Builder', function ($container) {
             return $container->make('Illuminate\\Database\\ConnectionInterface')->getSchemaBuilder();
         });
         if ($up) {
             $this->migrator->run($migrationDir, $extension);
         } else {
             $this->migrator->reset($migrationDir, $extension);
         }
     }
 }