feat: aggiungi supporto per superadmin in diverse risorse e aggiorna il modello utente
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('is_superadmin')->default(false)->after('password');
|
||||
});
|
||||
|
||||
// Superadmin iniziale: password provvisoria, da cambiare dal profilo.
|
||||
if (! DB::table('users')->where('email', 'admin@aurealab.net')->exists()) {
|
||||
DB::table('users')->insert([
|
||||
'name' => 'Superadmin',
|
||||
'email' => 'admin@aurealab.net',
|
||||
'password' => Hash::make('Aurealab-Kreios-2026!'),
|
||||
'is_superadmin' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
} else {
|
||||
DB::table('users')->where('email', 'admin@aurealab.net')->update(['is_superadmin' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('users')->where('email', 'admin@aurealab.net')->delete();
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('is_superadmin');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user