44 lines
932 B
PHP
44 lines
932 B
PHP
<?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');
|
|
});
|
|
}
|
|
};
|