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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -14,7 +14,7 @@ class DatabaseSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
// Utente amministratore del backoffice.
|
||||
User::updateOrCreate(
|
||||
User::firstOrCreate(
|
||||
['email' => 'admin@kreiosinfissi.it'],
|
||||
[
|
||||
'name' => 'Amministratore',
|
||||
@@ -22,6 +22,16 @@ class DatabaseSeeder extends Seeder
|
||||
]
|
||||
);
|
||||
|
||||
// Superadmin: vede anche le sezioni Prodotti e Configuratore.
|
||||
User::firstOrCreate(
|
||||
['email' => 'admin@aurealab.net'],
|
||||
[
|
||||
'name' => 'Superadmin',
|
||||
'password' => Hash::make('Aurealab-Kreios-2026!'),
|
||||
'is_superadmin' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->call([CatalogoSeeder::class, ConfiguratoreSeeder::class, ProfiliExtraSeeder::class, NuoveOpzioniSeeder::class]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user