70 lines
2.0 KiB
PHP
70 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Carbon\Carbon;
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
class AdminStandardSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
// Ruoli
|
|
$adminRole = Role::firstOrCreate(['name' => 'admin']);
|
|
$amministratoreRole = Role::firstOrCreate(['name' => 'amministratore']);
|
|
$condominoRole = Role::firstOrCreate(['name' => 'condomino']);
|
|
|
|
// Crea utente Admin Standard
|
|
$admin = User::firstOrCreate(
|
|
['email' => 'admin@netgescon.local'],
|
|
[
|
|
'name' => 'Admin Standard',
|
|
'password' => Hash::make('password'),
|
|
'email_verified_at' => Carbon::now(),
|
|
]
|
|
);
|
|
if (!$admin->hasRole('admin')) {
|
|
$admin->assignRole('admin');
|
|
}
|
|
|
|
// Crea utente Condomino di Test
|
|
$condomino = User::firstOrCreate(
|
|
['email' => 'condomino@test.local'],
|
|
[
|
|
'name' => 'Condomino Test',
|
|
'password' => Hash::make('password'),
|
|
'email_verified_at' => Carbon::now(),
|
|
]
|
|
);
|
|
if (!$condomino->hasRole('condomino')) {
|
|
$condomino->assignRole('condomino');
|
|
}
|
|
|
|
// Verifica utente Miki esistente
|
|
$miki = User::firstOrCreate(
|
|
['email' => 'miki@gmail.com'],
|
|
[
|
|
'name' => 'Miki Admin',
|
|
'password' => Hash::make('password'),
|
|
'email_verified_at' => Carbon::now(),
|
|
]
|
|
);
|
|
if (!$miki->hasRole('amministratore')) {
|
|
$miki->assignRole('amministratore');
|
|
}
|
|
|
|
$this->command->info('Utenti di test creati/aggiornati:');
|
|
$this->command->info('- admin@netgescon.local / password');
|
|
$this->command->info('- condomino@test.local / password');
|
|
$this->command->info('- miki@gmail.com / password');
|
|
}
|
|
}
|