12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- use App\Models\Setting;
- use App\Models\User;
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- return new class extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::table('users', function (Blueprint $table) {
- $table->boolean('disabled');
- });
- $disabledUsers = Setting::where('key', 'disabled')->where('value', 1)->get();
- foreach($disabledUsers as $u) {
- $user = User::where('id', $u->user)->first();
- $user->disabled = true;
- $user->save();
- }
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::table('users', function (Blueprint $table) {
- $table->dropColumn('disabled');
- });
- }
- };
|