当前位置: 首页>>代码示例>>PHP>>正文


PHP Schema::hasColumn方法代码示例

本文整理汇总了PHP中Schema::hasColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP Schema::hasColumn方法的具体用法?PHP Schema::hasColumn怎么用?PHP Schema::hasColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Schema的用法示例。


在下文中一共展示了Schema::hasColumn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: up

 /**
  * 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');
         });
     }
 }
开发者ID:syscover,项目名称:booking,代码行数:33,代码来源:2011_01_01_000004_booking_updateV4.php

示例2: testTableWasCreatedFromConfig

 /**
  * 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'));
 }
开发者ID:claremontdesign,项目名称:zbase,代码行数:11,代码来源:ZbaseTest.php

示例3: run

 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();
 }
开发者ID:aysenli,项目名称:admin,代码行数:35,代码来源:AdminDataSeeder.php

示例4: up

 /**
  * 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');
             });
         }
     }
 }
开发者ID:tallcoder,项目名称:Reservations,代码行数:34,代码来源:2013_12_27_132100_create_company_table.php

示例5: up

    /**
     * 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']);
                });
            }
        });
    }
开发者ID:joshdavis11,项目名称:hometeachme,代码行数:39,代码来源:2016_02_12_033548_remove_ward_id_from_comments.php

示例6: down

 /**
  * 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');
             }
         });
     }
 }
开发者ID:redooor,项目名称:redminportal,代码行数:31,代码来源:2015_09_18_000000_add_shipping_properties_to_products_table.php

示例7: up

 /**
  * 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');
             }
         });
     }
 }
开发者ID:devisephp,项目名称:cms,代码行数:31,代码来源:2014_08_29_160748_create_groups.php

示例8: up

 /**
  * 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);
     });
 }
开发者ID:hannenijhuis,项目名称:invoiceninja,代码行数:37,代码来源:2016_03_23_215049_support_multiple_tax_rates.php

示例9: up

 /**
  * 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');
             });
         }
     }
 }
开发者ID:tallcoder,项目名称:Reservations,代码行数:34,代码来源:2013_10_13_134447_create_user_table.php

示例10: up

 /**
  * 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);
     }
 }
开发者ID:syscover,项目名称:market,代码行数:35,代码来源:2012_01_01_000032_market_updateV32.php

示例11: processInstructions

 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;
         }
     }
 }
开发者ID:xmarkclx,项目名称:laravel-autodb,代码行数:29,代码来源:LaravelModelAssembler.php

示例12: up

 /**
  * 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');
         });
     }
 }
开发者ID:aguaragazu,项目名称:redminportal,代码行数:39,代码来源:2012_03_29_000000_create_users_table.php

示例13: up

 /**
  * 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);
     }
 }
开发者ID:syscover,项目名称:market,代码行数:12,代码来源:2012_01_01_000025_market_updateV25.php

示例14: up

 /**
  * 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();
         }
     });
 }
开发者ID:hannenijhuis,项目名称:invoiceninja,代码行数:13,代码来源:2016_03_14_214710_add_support_three_decimal_taxes.php

示例15: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (Schema::hasColumn('entries', 'user_id')) {
         Schema::table('entries', function ($table) {
             $table->dropColumn('user_id');
         });
     }
 }
开发者ID:shiccocsan,项目名称:laravel_simple_blog,代码行数:13,代码来源:2014_09_15_221844_ModifyEntryTable.php


注:本文中的Schema::hasColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。