本文整理汇总了PHP中Illuminate\Database\Connection::getSchemaBuilder方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getSchemaBuilder方法的具体用法?PHP Connection::getSchemaBuilder怎么用?PHP Connection::getSchemaBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Connection
的用法示例。
在下文中一共展示了Connection::getSchemaBuilder方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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: version
/**
* {@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: createSchema
/**
* 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: getSchemaBuilder
/**
* 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: getSchemaBuilder
public function getSchemaBuilder()
{
if (empty($this->builder)) {
return parent::getSchemaBuilder();
}
$class = $this->builder;
return new $class($this);
}
示例6: initialize
/**
* @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: __construct
/**
* Preparar Migration.
*/
public function __construct()
{
$this->con = app('db')->connection($this->getConnection());
$this->builder = $this->con->getSchemaBuilder();
$this->grammar = $this->con->getSchemaGrammar();
}
示例8: __construct
/**
* Construct an instance of a BaseMigration.
*/
public function __construct()
{
$this->db = app('db')->connection($this->connection);
$this->builder = $this->db->getSchemaBuilder();
}
示例9: tearDown
public function tearDown()
{
$this->connection->getSchemaBuilder()->dropIfExists('riders');
$this->connection->getSchemaBuilder()->dropIfExists('classes');
}
示例10: build
/**
* 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: __construct
public function __construct(Illuminate\Database\Connection $connection = NULL)
{
static::$connection = $connection ?: Forge::find('db.connection');
static::$schema = static::$connection->getSchemaBuilder();
static::$instance = $this;
}