PHP Method Schema::hasColumn, someline-starter Code Examples

This page contains top rated real world PHP examples of method Schema::hasColumn from package someline-starter extracted from open source projects. You can rate examples to help us improve the quality of examples
Frequently Used Methods

hasColumn() public static method

Determine if the given table has a given column.
public static hasColumn ( string $table, string $column ) : boolean
$table string
$column string
return boolean
Example #1
Show file File: 2011_01_01_000004_booking_updateV4.php Project: syscover/booking
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasColumn('011_225_booking', 'n_rooms_225')) {
         Schema::table('011_225_booking', function ($table) {
             $table->smallInteger('n_rooms_225')->unsigned()->nullable()->after('n_children_225');
         });
     }
     if (!Schema::hasColumn('011_225_booking', 'nights_225')) {
         Schema::table('011_225_booking', function ($table) {
             $table->smallInteger('nights_225')->unsigned()->nullable()->after('check_out_date_text_225');
         });
     }
     if (Schema::hasColumn('011_225_booking', 'room_description_225')) {
         Schema::table('011_225_booking', function ($table) {
             $table->renameColumn('room_description_225', 'object_description_225');
         });
     }
     if (Schema::hasColumn('011_225_booking', 'n_adult_225')) {
         Schema::table('011_225_booking', function ($table) {
             $table->renameColumn('n_adult_225', 'n_adults_225');
         });
     }
     if (Schema::hasColumn('011_225_booking', 'temporary_bed_225')) {
         Schema::table('011_225_booking', function ($table) {
             $table->renameColumn('temporary_bed_225', 'temporary_beds_225');
         });
     }
 }
Example #2
Show file File: ZbaseTest.php Project: claremontdesign/zbase
0
 /**
  * Test table was created based from config
  * @group entity
  */
 public function testTableWasCreatedFromConfig()
 {
     $this->assertTrue(Schema::hasTable('users'));
     $this->assertTrue(Schema::hasTable('users_profile'));
     $this->assertTrue(Schema::hasColumn('users', 'email'));
     $this->assertTrue(Schema::hasColumn('users_profile', 'first_name'));
 }
Example #3
Show file File: AdminDataSeeder.php Project: aysenli/admin
0
 public function run()
 {
     Model::unguard();
     DB::table('users')->delete();
     DB::table('roles')->delete();
     DB::table('role_user')->delete();
     DB::table('permission_role')->delete();
     DB::table('permissions')->delete();
     if (!Schema::hasColumn('permissions', 'isDisplay')) {
         Schema::table('permissions', function ($table) {
             $table->tinyInteger('isDisplay')->comment('是否显示在左侧菜单');
         });
     }
     if (!Schema::hasColumn('permissions', 'power')) {
         Schema::table('permissions', function ($table) {
             $table->string('power')->comment('权限正则');
         });
     }
     $user = User::create(['email' => 'admin@yingzt.com', 'name' => 'admin', 'password' => bcrypt('admin')]);
     // 创建组
     $admin = parent::createRole($this->roleName, "超级管理员组");
     $menuIds = array();
     $perant_id = parent::createPermission("/admin", "", "管理后台", 1, '$');
     $menuIds[] = $perant_id;
     $menuArray = [["name" => "admin/user", "display_name" => $perant_id, "description" => "账号管理", "isDisplay" => 1, "power" => '(.*)'], ["name" => "admin/role", "display_name" => $perant_id, "description" => "角色管理", "isDisplay" => 1, "power" => '(.*)'], ["name" => "admin/menu", "display_name" => $perant_id, "description" => "菜单管理", "isDisplay" => 1, "power" => '(.*)']];
     foreach ($menuArray as $value) {
         $menuIds[] = self::createPermission($value['name'], $value['display_name'], $value['description'], $value['isDisplay'], $value['power']);
     }
     // 添加用户组权限
     $admin->perms()->sync($menuIds);
     $user->attachRole($admin);
     // // 检查
     print_r("true\n");
     Model::reguard();
 }
Example #4
Show file File: 2013_12_27_132100_create_company_table.php Project: tallcoder/Reservations
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasTable('company')) {
         Schema::create('company', function ($table) {
             $table->increments('id');
             $table->unsignedInteger('cluster_id');
             $table->string('name');
             $table->string('domains');
             $table->string('logo_url');
             $table->timestamps();
         });
     } else {
         if (!Schema::hasColumn('company', 'name')) {
             Schema::table('company', function ($table) {
                 $table->string('name');
             });
         }
         if (!Schema::hasColumn('company', 'domains')) {
             Schema::table('company', function ($table) {
                 $table->string('domains');
             });
         }
         if (!Schema::hasColumn('company', 'logo_url')) {
             Schema::table('company', function ($table) {
                 $table->string('logo_url');
             });
         }
     }
 }
Example #5
Show file File: 2016_02_12_033548_remove_ward_id_from_comments.php Project: joshdavis11/hometeachme
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     DB::transaction(function () {
         $newDate = '2016-01-01 00:00:00';
         if (Schema::hasTable('comments')) {
             if (!Schema::hasColumn('comments', 'companionship_id')) {
                 Schema::table('comments', function (Blueprint $table) {
                     $table->integer('companionship_id')->unsigned()->after('member_id');
                 });
             }
             DB::update('UPDATE comments SET created_at = ?, updated_at = ? WHERE created_at = ?', [$newDate, $newDate, '0000-00-00 00:00:00']);
             DB::update('UPDATE ward_companions SET created_at = ?, updated_at = ? WHERE created_at = ?', [$newDate, $newDate, '0000-00-00 00:00:00']);
             $companionships = DB::select('
		SELECT c.id AS commentId, c.member_id AS commentMemberId, c.companion_id AS commentCompanion, wc.*, c.family_id
		FROM comments AS c
		LEFT JOIN ward_companions AS wc
		ON (ht_one_id = c.member_id OR ht_one_id = c.companion_id)
		AND (ht_two_id = c.member_id OR ht_two_id = c.companion_id)
		ORDER BY commentId ASC');
             $date = '2000-01-01 00:00:00';
             foreach ($companionships as $companionship) {
                 if (empty($companionship->id)) {
                     $member = DB::table('members')->find($companionship->commentMemberId);
                     DB::table('ward_companions')->insert(['ht_one_id' => $companionship->commentMemberId, 'ht_two_id' => $companionship->commentCompanion, 'ward_id' => $member->ward_id, 'district_id' => 0, 'quorum_id' => $member->quorum_id, 'family_id' => $companionship->family_id, 'created_at' => $date, 'updated_at' => $date, 'deleted_at' => $date]);
                     $companionship->id = DB::getPdo()->lastInsertId();
                 }
                 DB::update('UPDATE comments SET companionship_id = ? WHERE id = ?', [$companionship->id, $companionship->commentId]);
             }
             Schema::table('comments', function (Blueprint $table) {
                 $table->dropColumn(['ward_id', 'companion_id']);
             });
         }
     });
 }
Example #6
Show file File: 2015_09_18_000000_add_shipping_properties_to_products_table.php Project: redooor/redminportal
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     // Remove columns from products
     if (Schema::hasTable('products')) {
         Schema::table('products', function (Blueprint $table) {
             if (Schema::hasColumn('products', 'weight_unit')) {
                 $table->dropColumn('weight_unit');
             }
             if (Schema::hasColumn('products', 'volume_unit')) {
                 $table->dropColumn('volume_unit');
             }
             if (Schema::hasColumn('products', 'length')) {
                 $table->dropColumn('length');
             }
             if (Schema::hasColumn('products', 'width')) {
                 $table->dropColumn('width');
             }
             if (Schema::hasColumn('products', 'height')) {
                 $table->dropColumn('height');
             }
             if (Schema::hasColumn('products', 'weight')) {
                 $table->dropColumn('weight');
             }
         });
     }
 }
Example #7
Show file File: 2014_08_29_160748_create_groups.php Project: devisephp/cms
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasTable('groups')) {
         Schema::create('groups', function ($table) {
             $table->increments('id');
             $table->string('name', 255);
             $table->timestamp('created_at')->default('0000-00-00 00:00:00');
             $table->timestamp('updated_at')->default('0000-00-00 00:00:00');
         });
     } else {
         Schema::table('groups', function ($table) {
             if (!Schema::hasColumn('groups', 'id')) {
                 $table->increments('id');
             }
             if (!Schema::hasColumn('groups', 'name')) {
                 $table->string('name', 255);
             }
             if (!Schema::hasColumn('groups', 'created_at')) {
                 $table->timestamp('created_at')->default('0000-00-00 00:00:00');
             }
             if (!Schema::hasColumn('groups', 'updated_at')) {
                 $table->timestamp('updated_at')->default('0000-00-00 00:00:00');
             }
         });
     }
 }
Example #8
Show file File: 2016_03_23_215049_support_multiple_tax_rates.php Project: hannenijhuis/invoiceninja
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('invoices', function ($table) {
         if (Schema::hasColumn('invoices', 'tax_rate')) {
             $table->decimal('tax_rate', 13, 3)->change();
         }
     });
     Schema::table('invoice_items', function ($table) {
         if (Schema::hasColumn('invoice_items', 'tax_rate')) {
             $table->decimal('tax_rate', 13, 3)->change();
         }
     });
     Schema::table('invoices', function ($table) {
         if (Schema::hasColumn('invoices', 'tax_rate')) {
             $table->renameColumn('tax_rate', 'tax_rate1');
             $table->renameColumn('tax_name', 'tax_name1');
         }
         $table->string('tax_name2')->nullable();
         $table->decimal('tax_rate2', 13, 3);
     });
     Schema::table('invoice_items', function ($table) {
         if (Schema::hasColumn('invoice_items', 'tax_rate')) {
             $table->renameColumn('tax_rate', 'tax_rate1');
             $table->renameColumn('tax_name', 'tax_name1');
         }
         $table->string('tax_name2')->nullable();
         $table->decimal('tax_rate2', 13, 3);
     });
     Schema::table('accounts', function ($table) {
         $table->boolean('enable_client_portal_dashboard')->default(true);
     });
 }
Example #9
Show file File: 2013_10_13_134447_create_user_table.php Project: tallcoder/Reservations
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // checking the existence of the user table before adding
     if (!Schema::hasTable('user')) {
         Schema::create('user', function (Blueprint $table) {
             $table->increments('id');
             $table->timestamps();
             $table->string('username');
             $table->string('password');
             $table->integer('rights');
         });
     } else {
         if (!Schema::hasColumn('user', 'username')) {
             Schema::table('user', function ($table) {
                 $table->string('username');
             });
         }
         if (!Schema::hasColumn('user', 'password')) {
             Schema::table('user', function ($table) {
                 $table->string('password');
             });
         }
         if (!Schema::hasColumn('user', 'rights')) {
             Schema::table('user', function ($table) {
                 $table->integer('rights');
             });
         }
     }
 }
Example #10
Show file File: 2012_01_01_000032_market_updateV32.php Project: syscover/market
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // ***********************
     // 012_116_order
     // ***********************
     if (Schema::hasColumn('012_116_order', 'tax_amount_116')) {
         // tax_amount_116
         DBLibrary::renameColumn('012_116_order', 'tax_amount_116', 'tax_amount_116', 'DECIMAL', '12,4', false, false);
     }
     if (Schema::hasColumn('012_116_order', 'total_discount_amount_116')) {
         // total_discount_amount_116
         DBLibrary::renameColumn('012_116_order', 'total_discount_amount_116', 'discount_amount_116', 'DECIMAL', '12,4', false, false);
     }
     if (Schema::hasColumn('012_116_order', 'shipping_116')) {
         // shipping_116
         DBLibrary::renameColumn('012_116_order', 'shipping_116', 'shipping_amount_116', 'DECIMAL', '12,4', false, false);
     }
     if (!Schema::hasColumn('012_116_order', 'subtotal_with_discounts_116')) {
         Schema::table('012_116_order', function (Blueprint $table) {
             $table->decimal('subtotal_with_discounts_116', 12, 4)->after('discount_amount_116');
         });
     }
     // ***********************
     // 012_117_order_row
     // ***********************
     if (Schema::hasColumn('012_117_order_row', 'gift_117')) {
         // gift_117
         DBLibrary::renameColumn('012_117_order_row', 'gift_117', 'has_gift_117', 'TINYINT', 1, false, false);
     }
 }
Example #11
Show file File: LaravelModelAssembler.php Project: xmarkclx/laravel-autodb
0
 private function processInstructions()
 {
     /** @var Blueprint $table */
     $table = $this->table;
     // Add timestamps if not yet added
     if (!\Schema::hasColumn($this->tableName, 'created_at')) {
         $table->timestamps();
     }
     foreach ($this->assemblyInstructionSet->assemblyInstructions as $assemblyInstruction) {
         /** @var AssemblyInstruction $assemblyInstruction */
         switch ($assemblyInstruction->tag) {
             case '@property':
                 if (!\Schema::hasColumn($this->tableName, $assemblyInstruction->name)) {
                     if (!$assemblyInstruction->hasHashtags()) {
                         $table->{$assemblyInstruction->type}($assemblyInstruction->name);
                     } else {
                         $table->{$assemblyInstruction->getTypeTag()}($assemblyInstruction->name);
                     }
                 } else {
                     if (!$assemblyInstruction->hasHashtags()) {
                         $table->{$assemblyInstruction->type}($assemblyInstruction->name)->change();
                     } else {
                         $table->{$assemblyInstruction->getTypeTag()}($assemblyInstruction->name)->change();
                     }
                 }
                 break;
         }
     }
 }
Example #12
Show file File: 2012_03_29_000000_create_users_table.php Project: aguaragazu/redminportal
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (Schema::hasTable('users')) {
         // Add remember_token column to existing table
         if (!Schema::hasColumn('users', 'remember_token')) {
             Schema::table('users', function ($table) {
                 $table->rememberToken();
             });
         }
     } else {
         // Continue support of Cartalyst/Sentry schema
         Schema::create('users', function (Blueprint $table) {
             $table->increments('id');
             $table->string('email')->unique();
             $table->string('password', 60);
             $table->rememberToken();
             $table->timestamps();
             $table->text('permissions')->nullable();
             $table->boolean('activated')->default(0);
             $table->string('activation_code')->nullable();
             $table->timestamp('activated_at')->nullable();
             $table->timestamp('last_login')->nullable();
             $table->string('persist_code')->nullable();
             $table->string('reset_password_code')->nullable();
             $table->string('first_name')->nullable();
             $table->string('last_name')->nullable();
             // We'll need to ensure that MySQL uses the InnoDB engine to
             // support the indexes, other engines aren't affected.
             $table->engine = 'InnoDB';
             $table->index('activation_code');
             $table->index('reset_password_code');
         });
     }
 }
Example #13
Show file File: 2012_01_01_000025_market_updateV25.php Project: syscover/market
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (Schema::hasColumn('012_111_product', 'price_111')) {
         // price_111
         DBLibrary::renameColumn('012_111_product', 'price_111', 'subtotal_111', 'DECIMAL', '12,4', false, true);
     }
 }
Example #14
Show file File: 2013_11_23_163257_create_cluster_table.php Project: tallcoder/Reservations
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasTable('cluster')) {
         Schema::create('cluster', function (Blueprint $table) {
             $table->increments('id');
             $table->timestamps();
             $table->string('clustername');
             $table->string('password');
             $table->integer('user_id');
         });
     } else {
         if (!Schema::hasColumn('cluster', 'clustername')) {
             Schema::table('cluster', function ($table) {
                 $table->string('clustername');
             });
         }
         if (!Schema::hasColumn('cluster', 'password')) {
             Schema::table('cluster', function ($table) {
                 $table->string('password');
             });
         }
         if (!Schema::hasColumn('cluster', 'user_id')) {
             Schema::table('cluster', function ($table) {
                 $table->integer('user_id');
             });
         }
     }
 }
Example #15
Show file File: 2016_03_14_214710_add_support_three_decimal_taxes.php Project: hannenijhuis/invoiceninja
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('tax_rates', function ($table) {
         if (Schema::hasColumn('tax_rates', 'rate')) {
             $table->decimal('rate', 13, 3)->change();
         }
     });
 }
Example #16
Show file File: 2014_09_15_221844_ModifyEntryTable.php Project: shiccocsan/laravel_simple_blog
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (Schema::hasColumn('entries', 'user_id')) {
         Schema::table('entries', function ($table) {
             $table->dropColumn('user_id');
         });
     }
 }
Example #17
Show file File: 2015_08_14_020836_add_user_id_to_oauth_clients.php Project: alnutile/oauth_how_to
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('oauth_clients', function (Blueprint $table) {
         if (Schema::hasColumn('oauth_clients', 'user_id')) {
             $table->dropColumn('user_id');
         }
     });
 }
Example #18
Show file File: 2016_03_08_000000_add_api_token_to_users_table.php Project: jeremytubbs/igor
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (Schema::hasColumn('users', 'api_token')) {
         Schema::table('users', function (Blueprint $table) {
             $table->dropColumn('api_token');
         });
     }
 }
Example #19
Show file File: 2015_08_22_215958_AddArchivedToWardComments.php Project: joshdavis11/hometeachme
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (Schema::hasTable('ward_comments') && Schema::hasColumn('ward_comments', 'deleted_at')) {
         Schema::table('ward_comments', function ($table) {
             $table->dropColumn('deleted_at');
         });
     }
 }
Example #20
Show file File: 2016_07_17_083236_add_occupation_id_to_short_term_trainees_table.php Project: rdg577/laravel-mis
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (!Schema::hasColumn('short_term_trainees', 'occupation_id')) {
         Schema::table('short_term_trainees', function (Blueprint $table) {
             $table->dropColumn('occupation_id');
         });
     }
 }
Example #21
Show file File: 2015_12_11_225043_add_email_to_companies_table.php Project: vukanac/l5-admin-panel
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('companies', function (Blueprint $table) {
         if (Schema::hasColumn('companies', 'email')) {
             $table->dropColumn('email');
         }
     });
 }
Example #22
Show file File: 2015_02_22_135653_add_observations_to_response_ratings.php Project: adriancatalinsv/fiip
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasColumn('response_ratings', 'observations')) {
         Schema::table('response_ratings', function (Blueprint $table) {
             $table->mediumText('observations')->nullable();
         });
     }
 }
Example #23
Show file File: 2013_01_01_000005_cms_updateV5.php Project: syscover/cms
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasColumn('013_352_category', 'slug_352')) {
         Schema::table('013_352_category', function ($table) {
             $table->string('slug_352')->nullable()->after('name_352');
         });
     }
 }
Example #24
Show file File: 2016_02_21_205547_add_public_flag_to_events_table.php Project: umSoftEng2GrpE/partEZ
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (Schema::hasColumn('events', 'public')) {
         Schema::table('events', function ($table) {
             $table->dropColumn('public');
         });
     }
 }
Example #25
Show file File: 2011_01_01_000001_booking_updateV1.php Project: syscover/booking
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasColumn('011_226_voucher', 'has_used_226')) {
         Schema::table('011_226_voucher', function (Blueprint $table) {
             $table->boolean('has_used_226')->default(false)->after('active_226');
         });
     }
 }
Example #26
Show file File: 2014_01_30_135311_add_orders_pending_date_to_orders_table.php Project: carlosqueiroz/nosh-core
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasColumn('orders', 'orders_pending_date')) {
         Schema::table('orders', function (Blueprint $table) {
             $table->dateTime('orders_pending_date')->nullable();
         });
     }
 }
Example #27
Show file File: 2015_03_02_001937_add_observations_area_group.php Project: adriancatalinsv/fiip
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasColumn('observations', 'area_group_user')) {
         Schema::table('area_group_user', function (Blueprint $table) {
             $table->mediumText('observations')->nullable();
         });
     }
 }
Example #28
Show file File: 2016_03_02_004702_add_city_to_users_table.php Project: umSoftEng2GrpE/partEZ
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (Schema::hasColumn('users', 'city')) {
         Schema::table('users', function ($table) {
             $table->dropColumn('city');
         });
     }
 }
Example #29
Show file File: 2015_02_04_101443_add_quiz_questions_required_column.php Project: adriancatalinsv/fiip
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (Schema::hasColumn('quiz_questions', 'required')) {
         Schema::table('quiz_questions', function ($table) {
             $table->dropColumn('required');
         });
     }
 }
Example #30
Show file File: 2008_01_01_000001_octopus_updateV1.php Project: syscover/octopus
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasColumn('008_072_product', 'active_072')) {
         Schema::table('008_072_product', function (Blueprint $table) {
             $table->boolean('active_072')->after('name_072');
         });
     }
 }