getSchemaBuilder() public method

Get a schema builder instance for the connection.
public getSchemaBuilder ( ) : Illuminate\Database\Schema\Builder
return Illuminate\Database\Schema\Builder
コード例 #1
0
 /**
  * Create a new FieldTypeSchema instance.
  *
  * @param FieldType  $fieldType
  * @param Repository $cache
  */
 public function __construct(FieldType $fieldType, Container $container, Repository $cache)
 {
     $this->cache = $cache;
     $this->container = $container;
     $this->fieldType = $fieldType;
     $this->connection = $container->make('db')->connection();
     $this->schema = $this->connection->getSchemaBuilder();
 }
コード例 #2
0
ファイル: MigrateAdapter.php プロジェクト: wandu/framework
 /**
  * {@inheritdoc}
  */
 public function version($id)
 {
     $schema = $this->connection->getSchemaBuilder();
     if (!$schema->hasTable($this->tableName)) {
         return null;
     }
     $version = $this->connection->table($this->tableName)->where('version', $id)->first();
     if ($version) {
         return (array) $version;
     }
     return null;
 }
コード例 #3
0
ファイル: Database.php プロジェクト: davedevelopment/phpmig
 /**
  * Create Schema
  *
  * @return AdapterInterface
  */
 public function createSchema()
 {
     /* @var \Illuminate\Database\Schema\Blueprint $table */
     $this->adapter->getSchemaBuilder()->create($this->tableName, function ($table) {
         $table->string('version');
     });
 }
コード例 #4
0
 /**
  * Retrieve the schema builder for the database connection. And set a custom blueprint resolver to return an
  * instance of the Culpa Blueprint class.
  *
  * @param Connection $connection
  * @return \Illuminate\Database\Schema\Builder
  */
 protected static function getSchemaBuilder(Connection $connection)
 {
     $schemaBuilder = $connection->getSchemaBuilder();
     $schemaBuilder->blueprintResolver(function ($table, $callback) {
         return new Blueprint($table, $callback);
     });
     return $schemaBuilder;
 }
コード例 #5
0
ファイル: RemodelConnection.php プロジェクト: bapcat/remodel
 public function getSchemaBuilder()
 {
     if (empty($this->builder)) {
         return parent::getSchemaBuilder();
     }
     $class = $this->builder;
     return new $class($this);
 }
コード例 #6
0
ファイル: DatabaseSchema.php プロジェクト: tomzx/irc-stats
 /**
  * @param \Illuminate\Database\Connection $db
  */
 public function initialize(Connection $db)
 {
     $builder = $db->getSchemaBuilder();
     $tables = ['networks' => function (Blueprint $table) {
         $table->increments('id');
         $table->string('server');
         $table->unique(['server']);
     }, 'channels' => function (Blueprint $table) {
         $table->increments('id');
         $table->integer('network_id')->unsigned();
         $table->string('channel');
         $table->unique(['network_id', 'channel']);
         $table->foreign('network_id')->references('id')->on('networks');
     }, 'nicks' => function (Blueprint $table) {
         $table->increments('id');
         $table->integer('network_id')->unsigned();
         $table->string('nick');
         $table->unique(['network_id', 'nick']);
         $table->foreign('network_id')->references('id')->on('networks');
     }, 'logs' => function (Blueprint $table) {
         $table->increments('id');
         $table->integer('channel_id')->unsigned();
         $table->integer('nick_id')->unsigned();
         $table->timestamp('timestamp');
         $table->text('message');
         $table->foreign('channel_id')->references('id')->on('channels');
         $table->foreign('nick_id')->references('id')->on('nicks');
     }, 'words' => function (Blueprint $table) {
         $table->increments('id');
         $table->string('word', 40);
     }, 'logs_words' => function (Blueprint $table) {
         $table->increments('id');
         $table->integer('logs_id')->unsigned();
         $table->integer('word_id')->unsigned();
         $table->foreign('logs_id')->references('id')->on('logs');
         $table->foreign('word_id')->references('id')->on('words');
     }];
     foreach ($tables as $table => $callback) {
         if ($builder->hasTable($table)) {
             continue;
         }
         $builder->create($table, $callback);
     }
 }
コード例 #7
0
ファイル: Migration.php プロジェクト: bugotech/database
 /**
  * Preparar Migration.
  */
 public function __construct()
 {
     $this->con = app('db')->connection($this->getConnection());
     $this->builder = $this->con->getSchemaBuilder();
     $this->grammar = $this->con->getSchemaGrammar();
 }
コード例 #8
0
 /**
  * Construct an instance of a BaseMigration.
  */
 public function __construct()
 {
     $this->db = app('db')->connection($this->connection);
     $this->builder = $this->db->getSchemaBuilder();
 }
 public function tearDown()
 {
     $this->connection->getSchemaBuilder()->dropIfExists('riders');
     $this->connection->getSchemaBuilder()->dropIfExists('classes');
 }
コード例 #10
0
ファイル: I18NBlueprint.php プロジェクト: tuanlq11/dbi18n
 /**
  * Overrride build function
  *
  * @param Connection $connection
  * @param Grammar    $grammar
  */
 public function build(Connection $connection, Grammar $grammar)
 {
     $command = $this->parseCommand($this->commands[0]->get('name'));
     $schema = $connection->getSchemaBuilder();
     if ($command === "drop") {
         $schema->dropIfExists($this->getI18NTableName());
     }
     parent::build($connection, $grammar);
     if ($command === "create") {
         $primary = $this->i18n_primary;
         $i18n_columns = $this->i18n_columns;
         $table_name = $this->table;
         $schema->create($this->getI18NTableName(), function (Blueprint $table) use($table_name, $primary, $i18n_columns) {
             foreach ($primary as $name => $col) {
                 $table->columns[] = $col;
                 $table->foreign($col->get('name'))->references($col->get('name'))->on($table_name)->onDelete('cascade');
             }
             foreach ($i18n_columns as $col) {
                 $table->columns[] = $col;
             }
             $table->string($this->i18n_code_field, 10);
             $table->primary(array_merge(array_keys($primary), [$this->i18n_code_field]));
         });
     }
 }
コード例 #11
0
ファイル: Schema.php プロジェクト: formula9/framework
 public function __construct(Illuminate\Database\Connection $connection = NULL)
 {
     static::$connection = $connection ?: Forge::find('db.connection');
     static::$schema = static::$connection->getSchemaBuilder();
     static::$instance = $this;
 }