作者:productionE
项目:pockeyt-ap
/**
* @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();
});
}
作者:xpressengin
项目:xpressengin
/**
*
*/
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'));
});
}
作者:UTNiano
项目:2.
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);
});
}
作者:chatbox-in
项目:toke
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");
});
}
作者:jarischaefe
项目:hal-ap
/**
* 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;
}
作者:AshniSukho
项目:UOM_connec
/**
* Undo the migration
*/
public function down()
{
//Remove Field
$this->schema->table('user_details', function ($table) {
$table->dropColumn('profile_picture');
});
}
作者:AshniSukho
项目:UOM_connec
/**
* 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');
}
作者:samharrison
项目:files-field_typ
/**
* 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());
}
作者:bloveles
项目:multiple-field_typ
/**
* 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());
}
作者:hugleste
项目:streams-platfor
/**
* 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);
});
}
作者:AshniSukho
项目:UOM_connec
/**
* 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');
}
作者:AshniSukho
项目:UOM_connec
/**
* 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');
}
作者:muratspla
项目:multilan
/**
* 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());
});
}
作者:samharrison
项目:files-field_typ
/**
* 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']);
});
}
作者:ash-rai
项目:oauth2-server-larave
/**
* 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();
});
}
作者:bloveles
项目:multiple-field_typ
/**
* Handle the event.
*
* @param AssignmentWasCreated $event
*/
public function handle(AssignmentWasCreated $event)
{
$assignment = $event->getAssignment();
$fieldType = $assignment->getFieldType();
if (!$fieldType instanceof MultipleFieldType) {
return;
}
$table = array_get($fieldType->getConfig(), 'pivot_table', $assignment->getStreamPrefix() . $assignment->getStreamSlug() . '_' . $fieldType->getField());
$foreignKey = $fieldType->getForeignKey();
$otherKey = $fieldType->getOtherKey();
$this->schema->dropIfExists($table);
$this->schema->create($table, function (Blueprint $table) use($foreignKey, $otherKey) {
$table->increments('id');
$table->integer($foreignKey);
$table->integer($otherKey);
});
}
作者:jacksun10
项目:streams-platfor
/**
* Drop a column.
*
* @param $table
* @param FieldType $type
*/
public function dropColumn($table, FieldType $type)
{
$schema = $type->getSchema();
if (!$this->schema->hasTable($table)) {
return;
}
$this->schema->table($table, function (Blueprint $table) use($schema) {
$schema->dropColumn($table);
});
}
作者:jacksun10
项目:streams-platfor
/**
* Clean up abandoned streams.
*/
public function cleanup()
{
/* @var StreamInterface $stream */
foreach ($this->model->all() as $stream) {
if (!$this->schema->hasTable($stream->getEntryTableName())) {
$this->delete($stream);
}
}
$translations = $this->model->getTranslationModel();
$translations->leftJoin('streams_streams', 'streams_streams_translations.stream_id', '=', 'streams_streams.id')->whereNull('streams_streams.id')->delete();
}
作者:offwork
项目:laraquen
/**
* Create table if not exist.
* @param string table
* @param \Closure $callback
*/
public function table($table, \Closure $callback)
{
try {
parent::create($table, $callback);
} catch (\Exception $e) {
try {
parent::table($table, $callback);
} catch (\Exception $e) {
echo $e->getMessage();
}
}
}
作者:frankkessle
项目:salesforce-laravel-oauth2-res
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if ($connection = Capsule::connection($this->getConnection())) {
$connection->useDefaultSchemaGrammar();
} else {
$app = app();
$connection = $app['db']->connection($this->getConnection());
}
$schema = new Schema($connection);
if (!$schema->hasTable('salesforce_tokens')) {
$schema->create('salesforce_tokens', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('access_token');
$table->string('refresh_token');
$table->string('instance_base_url');
$table->bigInteger('user_id');
$table->datetime('expires')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
}