PHP Schema::hasColumns Examples

PHP Schema::hasColumns - 2 examples found. These are the top rated real world PHP examples of Schema::hasColumns extracted from open source projects. You can rate examples to help us improve the quality of examples.

hasColumns() public static method

Determine if the given table has given columns.
public static hasColumns ( string $table, array $columns ) : boolean
$table string
$columns array
return boolean
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (Schema::hasTable('hlogeon_scms_types')) {
         if (Schema::hasColumns('hlogeon_scms_types', ['list_layout_id', 'enable_own_sidebar'])) {
             Schema::table('hlogeon_scms_types', function (Blueprint $table) {
                 $table->dropColumn('list_layout_id');
                 $table->dropColumn('type_layout_id');
                 $table->dropColumn('enable_own_sidebar');
                 $table->string('type_layout');
             });
         }
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasTable('users')) {
         Schema::create('users', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name');
             $table->string('email')->unique();
             $table->string('password', 60);
             $table->rememberToken();
             // Two-Factor Authentication Columns...
             $table->string('phone_country_code')->nullable();
             $table->string('phone_number')->nullable();
             $table->text('two_factor_options')->nullable();
             // Team Columns...
             $table->integer('current_team_id')->nullable();
             // Cashier Columns...
             $table->tinyInteger('stripe_active')->default(0);
             $table->string('stripe_id')->nullable();
             $table->string('stripe_subscription')->nullable();
             $table->string('stripe_plan', 100)->nullable();
             $table->string('last_four', 4)->nullable();
             $table->text('extra_billing_info')->nullable();
             $table->timestamp('trial_ends_at')->nullable();
             $table->timestamp('subscription_ends_at')->nullable();
             $table->timestamps();
         });
     } else {
         Schema::table('users', function (Blueprint $table) {
             if (!Schema::hasColumn('users', 'name')) {
                 $table->string('name');
             }
             if (!Schema::hasColumn('users', 'email')) {
                 $table->string('email')->unique();
             }
             if (!Schema::hasColumn('users', 'password')) {
                 $table->string('password', 60);
             }
             if (!Schema::hasColumn('users', 'remember_token')) {
                 $table->rememberToken();
             }
             if (!Schema::hasColumn('users', 'phone_country_code')) {
                 $table->string('phone_country_code')->nullable();
             }
             if (!Schema::hasColumn('users', 'phone_number')) {
                 $table->string('phone_number')->nullable();
             }
             if (!Schema::hasColumn('users', 'two_factor_options')) {
                 $table->text('two_factor_options')->nullable();
             }
             if (!Schema::hasColumn('users', 'current_team_id')) {
                 $table->integer('current_team_id')->nullable();
             }
             if (!Schema::hasColumn('users', 'stripe_active')) {
                 $table->tinyInteger('stripe_active')->default(0);
             }
             if (!Schema::hasColumn('users', 'stripe_id')) {
                 $table->string('stripe_id')->nullable();
             }
             if (!Schema::hasColumn('users', 'stripe_subscription')) {
                 $table->string('stripe_subscription')->nullable();
             }
             if (!Schema::hasColumn('users', 'stripe_plan')) {
                 $table->string('stripe_plan', 100)->nullable();
             }
             if (!Schema::hasColumn('users', 'last_four')) {
                 $table->string('last_four', 4)->nullable();
             }
             if (!Schema::hasColumn('users', 'extra_billing_info')) {
                 $table->text('extra_billing_info')->nullable();
             }
             if (!Schema::hasColumn('users', 'trial_ends_at')) {
                 $table->timestamp('trial_ends_at')->nullable();
             }
             if (!Schema::hasColumn('users', 'subscription_ends_at')) {
                 $table->timestamp('subscription_ends_at')->nullable();
             }
             if (!Schema::hasColumns('users', ['created_at', 'updated_at'])) {
                 $table->timestamps();
             }
         });
     }
 }