本文整理汇总了PHP中Illuminate\Database\Schema\Builder类的典型用法代码示例。如果您正苦于以下问题:PHP Builder类的具体用法?PHP Builder怎么用?PHP Builder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scopeVisible
/**
* @param Builder|\Illuminate\Database\Eloquent\Builder|Model $query
* @return mixed
*/
public function scopeVisible($query)
{
return $query->whereHas('profile', function ($query) {
/** @var Profile $query */
return $query->visible();
});
}
示例2: createDivision
/**
*
*/
public function createDivision(Builder $schema, $table)
{
$schema->create($table, function (Blueprint $table) {
$table->engine = "InnoDB";
$table->string('id', 255);
$table = $this->setColumns($table);
$table->primary(array('id'));
});
}
示例3: __construct
public function __construct()
{
// get custom schema object
$this->schema = \DB::connection()->getSchemaBuilder();
// bind new blueprint class
$this->schema->blueprintResolver(function ($table, $callback) {
return new Blueprint($table, $callback);
});
}
示例4: upTable
public function upTable(Builder $builder)
{
$builder->create($this->table, function (Blueprint $blueprint) {
$blueprint->increments("id");
$blueprint->string("key")->unique();
$blueprint->string("tag");
$blueprint->text("value");
$blueprint->timestamp("created_at");
});
}
示例5: getMissingUpdateAttributes
/**
* POST and PUT requests must contain all attributes.
* This method returns all fillable attributes which are missing.
*
* @param Model $model
* @return array
*/
protected function getMissingUpdateAttributes(Model $model)
{
$keys = array_keys($this->body->getArray());
$columnNames = $this->schemaBuilder->getColumnListing($model->getTable());
$attributes = [];
foreach ($columnNames as $column) {
if ($model->isFillable($column) && !in_array($column, $keys)) {
$attributes[] = $column;
}
}
return $attributes;
}
示例6: down
/**
* Undo the migration
*/
public function down()
{
//Remove Field
$this->schema->table('user_details', function ($table) {
$table->dropColumn('profile_picture');
});
}
开发者ID:AshniSukhoo,项目名称:UOM_connect,代码行数:10,代码来源:20160128181212_AddProfilePictureFieldToUserDetailsTable.php
示例7: down
/**
* Undo the migration
*/
public function down()
{
$this->schema->table('user_works', function ($table) {
$table->dropForeign('user_works_user_id_foreign');
});
//Drop table
$this->schema->dropIfExists('user_works');
}
示例8: handle
/**
* Handle the event.
*
* @param AssignmentWasDeleted $event
*/
public function handle(AssignmentWasDeleted $event)
{
$assignment = $event->getAssignment();
$fieldType = $assignment->getFieldType();
if (!$fieldType instanceof FilesFieldType) {
return;
}
$this->schema->dropIfExists($table = $assignment->getStreamPrefix() . $assignment->getStreamSlug() . '_' . $fieldType->getField());
}
示例9: handle
/**
* Handle the event.
*
* @param AssignmentWasDeleted $event
*/
public function handle(AssignmentWasDeleted $event)
{
$assignment = $event->getAssignment();
$fieldType = $assignment->getFieldType();
if (!$fieldType instanceof MultipleFieldType) {
return;
}
$this->schema->dropIfExists($fieldType->getPivotTableName());
}
示例10: handle
/**
* Install the extensions table.
*/
public function handle()
{
$this->schema->dropIfExists('addons_extensions');
$this->schema->create('addons_extensions', function (Blueprint $table) {
$table->increments('id');
$table->string('slug');
$table->boolean('installed')->default(0);
$table->boolean('enabled')->default(0);
});
}
示例11: down
/**
* Undo the migration
*/
public function down()
{
//Drop foreign keys
$this->schema->table('friend_requests', function ($table) {
$table->dropForeign('friend_requests_sender_foreign');
$table->dropForeign('friend_requests_receiver_foreign');
});
//Drop table
$this->schema->dropIfExists('friend_requests');
}
示例12: down
/**
* Undo the migration
*/
public function down()
{
//Drop foreign keys
$this->schema->table('lecturers_courses_faculties', function ($table) {
$table->dropForeign('lecturer_courses_faculties_uom_id_foreign');
$table->dropForeign('lecturer_courses_faculties_faculty_id_foreign');
$table->dropForeign('lecturer_courses_faculties_course_id_foreign');
});
//Drop table
$this->schema->dropIfExists('lecturers_courses_faculties');
}
开发者ID:AshniSukhoo,项目名称:UOM_connect,代码行数:14,代码来源:20160302175103_CreateLecturerFacultyCoursesTable.php
示例13: getColumnsOnCache
/**
* To get all columns on caching
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return array
*/
protected function getColumnsOnCache(Model $model)
{
/**
* In normal scenario tables and columns often is not changed.
* Therefore every time it is not need to access the database for knowing
* columns name. We don't want make preoccupy/busy to the database.
*/
$fullKey = $this->getFullName($model);
return $this->cache->remember($fullKey, $this->getRememberTime(), function () use($model) {
return $this->builder->getColumnListing($model->getTable());
});
}
示例14: handle
/**
* Handle the event.
*
* @param AssignmentWasCreated $event
*/
public function handle(AssignmentWasCreated $event)
{
$assignment = $event->getAssignment();
$fieldType = $assignment->getFieldType();
if (!$fieldType instanceof FilesFieldType) {
return;
}
$table = $assignment->getStreamPrefix() . $assignment->getStreamSlug() . '_' . $fieldType->getField();
$this->schema->dropIfExists($table);
$this->schema->create($table, function (Blueprint $table) {
$table->integer('entry_id');
$table->integer('file_id');
$table->integer('sort_order')->nullable();
$table->primary(['entry_id', 'file_id']);
});
}
示例15: createTokenScopesTable
/**
* Create the token scopes table.
*
* @return void
*/
protected function createTokenScopesTable()
{
$this->schema->create($this->tables['token_scopes'], function ($table) {
$table->increments('id');
$table->string('token', 40)->index();
$table->string('scope')->index();
});
}