Esempio n. 1
1
 /**
  * @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();
     });
 }
 /**
  * Undo the migration
  */
 public function down()
 {
     //Remove Field
     $this->schema->table('user_details', function ($table) {
         $table->dropColumn('profile_picture');
     });
 }
 /**
  * Undo the migration
  */
 public function down()
 {
     //Remove url column
     $this->schema->table('notifications', function ($table) {
         $table->dropColumn('url');
     });
 }
 /**
  * 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');
 }
 /**
  * Undo the migration
  */
 public function down()
 {
     $this->schema->table('users_basic_info', function ($table) {
         $table->dropForeign('users_basic_info_user_id_foreign');
     });
     //Drop table
     $this->schema->dropIfExists('users_basic_info');
 }
 /**
  * Undo the migration
  */
 public function down()
 {
     //Drop foreign
     $this->schema->table('likes', function ($table) {
         $table->dropForeign('likes_user_id_foreign');
     });
     $this->schema->dropIfExists('likes');
 }
 /**
  *
  */
 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'));
     });
 }
 /**
  * Undo the migration
  */
 public function down()
 {
     //Drop foreign
     $this->schema->table('account_verification_tokens', function ($table) {
         $table->dropForeign('account_verification_tokens_user_id_foreign');
     });
     //Drop the table
     $this->schema->dropIfExists('account_verification_tokens');
 }
 /**
  * Undo the migration
  */
 public function down()
 {
     //Drop foreign keys
     $this->schema->table('passwords', function ($table) {
         $table->dropForeign('passwords_user_id_foreign');
     });
     //Drop passwords table
     $this->schema->dropIfExists('passwords');
 }
 /**
  * Undo the migration
  */
 public function down()
 {
     //Drop foreign
     $this->schema->table('user_details', function ($table) {
         $table->dropForeign('user_details_user_id_foreign');
     });
     //Drop user details table
     $this->schema->dropIfExists('user_details');
 }
 /**
  * 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());
 }
Esempio n. 12
0
 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);
     });
 }
 /**
  * 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());
 }
 /**
  * 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);
     });
 }
Esempio n. 15
0
 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");
     });
 }
 /**
  * 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');
 }
 /**
  * Undo the migration
  */
 public function down()
 {
     //Drop foreign keys
     $this->schema->table('friends', function ($table) {
         $table->dropForeign('friends_user_id_1_foreign');
         $table->dropForeign('friends_user_id_2_foreign');
     });
     //Drop table
     $this->schema->dropIfExists('friends');
 }
 /**
  * Undo the migration
  */
 public function down()
 {
     //Drop foreign keys
     $this->schema->table('users', function ($table) {
         $table->dropForeign('users_uom_id_foreign');
         $table->dropForeign('users_account_status_foreign');
     });
     //Drop the table
     $this->schema->dropIfExists('users');
 }
 /**
  * Undo the migration
  */
 public function down()
 {
     //Drop foreign keys
     $this->schema->table('notifications', function ($table) {
         $table->dropForeign('notifications_receiver_foreign');
         $table->dropForeign('notifications_notifier_foreign');
     });
     //Drop notifications table
     $this->schema->dropIfExists('notifications');
 }
 /**
  * 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');
 }
Esempio n. 21
0
 /**
  * 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());
     });
 }
 /**
  * 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']);
     });
 }
 /**
  * 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();
     });
 }
 /**
  * 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);
     });
 }
 /**
  * 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);
     });
 }
 /**
  * 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();
 }
 /**
  * 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;
 }
Esempio n. 28
0
 /**
  * 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();
         }
     }
 }
 /**
  * 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();
         });
     }
 }
 /**
  * Drop the field type column from the table.
  *
  * @param Blueprint $table
  */
 public function dropColumn(Blueprint $table)
 {
     // Skip if no column type.
     if (!$this->fieldType->getColumnType()) {
         return;
     }
     // Skip if the column doesn't exist.
     if (!$this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName())) {
         return;
     }
     // Drop dat 'ole column.
     $table->dropColumn($this->fieldType->getColumnName());
 }