public static function _schema_profilemodel(\Illuminate\Database\Schema\Blueprint $table) { $table->unsignedInteger('user_id'); $table->text('avatar'); $table->index(['user_id']); return $table; }
public static function _schema_multiStatusTrait(\Illuminate\Database\Schema\Blueprint $table) { $status = static::$AllowedStatus; $default = $status[0]; $table->enum('status', $status)->default($default); if (isset(static::$StatusDateTime)) { foreach (static::$StatusDateTime as $column) { if (!in_array($column, ['created_at', 'updated_at', 'deleted_at'])) { $table->dateTime($column)->nullable(); } } } $table->index(['status']); return $table; }
protected function create(Blueprint $table) { $table->create(); $table->string('conf_name', 255)->default(''); $table->text('conf_value')->nullable(); $table->primary('conf_name'); }
public static function _schema_tagModel(\Illuminate\Database\Schema\Blueprint $table) { $table->text('name')->nullable(); $table->string('type')->default('default'); $table->morphs('taggable'); return $table; }
protected function create(Blueprint $table) { $table->create(); $table->integer('user_id')->unsigned(); $table->integer('topic_id')->unsigned(); $table->primary(array('user_id', 'topic_id')); }
protected function create(Blueprint $table) { $table->create(); $table->increments('id'); $table->string('title', 50)->default(''); $table->integer('parent_group_id')->unsigned()->nullable(); }
/** * Add confirmation columns. * * @param \Illuminate\Database\Schema\Blueprint $table */ private function addConfirmationColumns(Blueprint $table) { if (UserConfirmator::isEnabled()) { $table->boolean('is_confirmed')->default(0); $table->string('confirmation_code', UserConfirmator::getLength())->nullable(); $table->timestamp('confirmed_at')->nullable(); } }
/** * Compile the blueprint's inherits definitions. * * @param BaseBlueprint $blueprint * @return array */ protected function getInheritedTables(BaseBlueprint $blueprint) { $tables = []; foreach ($blueprint->getInheritedTables() as $table) { //$sql = $this->wrapTable($table); $tables[] = $table; } return $tables; }
/** * Execute the blueprint to build / modify the table. * * @param \Cooperl\Database\DB2\Schema\Blueprint $blueprint * @return void */ protected function build(Blueprint $blueprint) { $schemaTable = explode(".", $blueprint->getTable()); if (count($schemaTable) > 1) { $this->connection->setCurrentSchema($schemaTable[0]); } $blueprint->build($this->connection, $this->grammar); $this->connection->resetCurrentSchema(); }
protected function buildDynamicTable(Blueprint $table) { $reference_column = $this->getDynamicType() . '_id'; $reference_table = $this->getDynamicType() . 's'; $reference_index = 'FK_' . $this->getDynamicTableName() . '_' . $reference_column . '_' . $reference_table; $table->increments('id'); $table->integer($reference_column)->unsigned()->nullable(); $table->foreign($reference_column, $reference_index)->references('id')->on($reference_table)->onUpdate('CASCADE')->onDelete('SET NULL'); $table->timestamps(); }
public function testIndexDefaultNames() { $blueprint = new Blueprint('users'); $blueprint->unique(array('foo', 'bar')); $commands = $blueprint->getCommands(); $this->assertEquals('users_foo_bar_unique', $commands[0]->index); $blueprint = new Blueprint('users'); $blueprint->index('foo'); $commands = $blueprint->getCommands(); $this->assertEquals('users_foo_index', $commands[0]->index); }
/** * @param Blueprint $table * @return Blueprint */ public static function _schema_LoginableTrait(Blueprint $table) { $table->string('password')->nullable(); $table->rememberToken('remember_token'); $table->dateTime('last_login')->nullable(); $table->string('last_ip')->nullable(); $table->integer('fails')->default(0); $table->enum('is_banned', [0, 1])->default(0); $table->text('ban_reason')->nullable(); $table->enum('locked_screen', [0, 1])->default(0); return $table; }
protected function create(Blueprint $table) { $table->create(); $table->string('id', 40); $table->integer('user_id')->unsigned()->default(1); $table->integer('created')->unsigned()->default(0); $table->integer('last_activity')->unsigned()->default(0); $table->string('last_ip', 200)->default('0.0.0.0'); $table->text('payload'); $table->primary('id'); $table->index('user_id'); }
/** * get qualified autoincrement column * * @param Blueprint $blueprint * @return Fluent|null */ public function getQualifiedAutoIncrementColumn(Blueprint $blueprint) { $columns = $blueprint->getColumns(); // search for primary key / autoIncrement column foreach ($columns as $column) { // if column is autoIncrement set the primary col name if ($column->autoIncrement) { return $column; } } return null; }
/** * Give me the tools and I will tell you what my schema is... * * @param Blueprint $table The blueprint for the database table. * @return Blueprint The designed database table schema. */ public static function describeSchema(Blueprint $table) { $table->increments('id'); $table->string('uuid', 36); $table->integer('playhead')->unsigned(); $table->text('metadata'); $table->text('payload'); $table->string('recorded_on', 32); $table->text('type'); $table->unique(['uuid', 'playhead']); return $table; }
/** * @return Blueprint|null */ public function getBlueprint() { if ($this->hasPivotTable()) { $left = $this->buildLeftColumnName(); $right = $this->getColumn(); $table = $this->getTable(); $blueprint = new Blueprint($table); $blueprint->increments('id'); $blueprint->integer($left); $blueprint->integer($right); return $blueprint; } }
public static function _schema_imageModel(Blueprint $table) { $table->string('image'); $table->string('url'); $table->unsignedInteger('order')->default(0); $table->string('type')->default('default'); $table->integer('width'); $table->integer('height'); $table->morphs('imageable'); return $table; }
public static function _schema_activityTrait(\Illuminate\Database\Schema\Blueprint $table) { $table->dateTime('activity_start')->nullable(); $table->dateTime('activity_end')->nullable(); $table->dateTime('signup_start')->nullable(); $table->dateTime('signup_end')->nullable(); $table->text('activity_title')->nullable(); $table->longText('activity_content')->nullable(); $table->morphs('owner'); return $table; }
public static function _schema_UserModel(Blueprint $table) { $table->string('email')->nullable()->label('邮箱'); $table->string('mobile')->nullable()->label('手机号码'); $table->string('username')->nullable()->label('姓名'); $table->string('nickname')->nullable()->label('昵称'); $table->enum('gender', ['未填' => '未填', '男' => '男', '女' => '女'])->default('未填')->label('性别'); $table->string('avatar')->nullable()->label('头像'); $table->date('birthday')->nullable()->label('生日'); return $table; }
/** * Add a foreign key to table and defer its foreign key creation. * * @param string $fk * @param string $column * @param string $keyName * @param string $onDelete * @param string $onUpdate * @return \Illuminate\Support\Fluent */ public function add($fk, $column = null, $keyName = null, $onDelete = null, $onUpdate = null) { $baseFk = $this->baseFk($fk); $column = $column ?: $baseFk->defaultColumn(); static::$foreignKeys[] = ['column' => $column ?: $this->column, 'key_name' => $keyName ?: $this->keyName, 'table' => $this->table->getTable(), 'reference_table' => $baseFk->referenceTable(), 'primary_key' => $baseFk->primaryKey, 'on_delete' => $onDelete ?: $this->onDelete ?: $baseFk->onDelete, 'on_update' => $onUpdate ?: $this->onUpdate ?: $baseFk->onUpdate]; return $baseFk->createFkColumn($column); }
/** * @param Blueprint $table * @return Blueprint */ public static function _schema(Blueprint $table) { $class = get_called_class(); $ref = new \ReflectionClass($class); $methods = $ref->getMethods(\ReflectionMethod::IS_STATIC); $table->engine = 'InnoDB'; $table->increments('id'); foreach ($methods as $method) { if (preg_match('/^_schema_.*/', $method->name)) { $name = $method->name; $table = static::$name($table); } } $table->softDeletes(); $table->timestamps(); return $table; }
/** * Add column only if there isn't one. * So it will not throw if there already exists. */ public function addColumn($type, $column, array $parameters = array()) { // check against existing if (!$this->builder->hasColumn($this->table, $column)) { return parent::addColumn($type, $column, $parameters); } // else probably compare and do some alteration }
/** * * @return $this */ public function timestamps($timestamps = true) { $this->timestamps = $timestamps; if ($timestamps && !Schema::hasTable($this->table)) { $this->blueprint->timestamps(); } return $this; }
protected function create(Blueprint $table) { $table->create(); $table->integer('group_id')->unsigned(); $table->integer('forum_id')->unsigned(); $table->boolean('read_forum')->default(true); $table->boolean('post_replies')->default(true); $table->boolean('post_topics')->default(true); $table->primary(array('group_id', 'forum_id')); }
protected function buildDynamicTable(Blueprint $table) { $block_index = 'FK_' . $this->getDynamicTableName() . '_block_id_blocks'; $page_index = 'FK_' . $this->getDynamicTableName() . '_page_id_pages'; $table->increments('id'); $table->integer('block_id')->unsigned()->nullable(); $table->integer('page_id')->unsigned()->nullable(); $table->integer('is_shared')->unsigned()->nullable(); $table->foreign('block_id', $block_index)->references('id')->on('blocks')->onUpdate('CASCADE')->onDelete('SET NULL'); $table->foreign('page_id', $page_index)->references('id')->on('pages')->onUpdate('CASCADE')->onDelete('SET NULL'); $table->timestamps(); }
public static function _schema_roles(\Illuminate\Database\Schema\Blueprint $table) { $table->integer('parent_id'); $table->string('name')->unique(); $table->longText('permissions'); $table->string('title'); $table->text('desc')->nullable(); return $table; }
protected function create(Blueprint $table) { $table->create(); $table->string('slug', 100)->primary(); $table->string('name'); $table->integer('position')->default(0); $table->boolean('conversations_enabled')->default(true); $table->timestamps(); }
/** * Create the table schema. * * @param Blueprint $table * * @return mixed */ protected function create(Blueprint $table) { $table->increments('id'); $table->text('public_id'); $table->text('secret_key'); $table->string('type'); $table->text('data'); $table->timestamps(); }
/** * @param Blueprint $table * @param AssignmentInterface $assignment */ public function addColumn(Blueprint $table, AssignmentInterface $assignment) { // Skip if the column already exists. if ($this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName())) { return; } /** * Add the column to the table. * * @var Blueprint|Fluent $column */ $column = $table->{$this->fieldType->getColumnType()}($this->fieldType->getColumnName(), 11, array_get($this->fieldType->getConfig(), 'decimals', 2))->nullable(!$assignment->isTranslatable() ? !$assignment->isRequired() : true); if (!str_contains($this->fieldType->getColumnType(), ['text', 'blob'])) { $column->default(array_get($this->fieldType->getConfig(), 'default_value')); } // Mark the column unique if desired and not translatable. if ($assignment->isUnique() && !$assignment->isTranslatable()) { $table->unique($this->fieldType->getColumnName()); } }
/** * Create the table schema. * * @param Blueprint $table * * @return mixed */ protected function create(Blueprint $table) { $table->increments('id'); $table->unsignedInteger('job_id'); $table->string('name'); $table->unique(['job_id', 'name']); $table->timestamps(); }