<?php
namespace Database\Seeders;
use App\Modules\User\Models\User;
use Illuminate\Database\Seeder;
/**
* AdminUserSeeder
*
* Creates the default super-admin account.
* NOTE: Do NOT use Hash::make() — the User model has 'password' => 'hashed' cast
* which auto-hashes on assignment. Double-hashing breaks login.
* IMPORTANT: Change the password immediately after first login in production.
*/
class AdminUserSeeder extends Seeder
{
public function run(): void
{
$admin = User::updateOrCreate(
['email' => 'admin@stpecommerce.com'],
[
'name' => 'Super Admin',
'email' => 'admin@stpecommerce.com',
'password' => 'Admin@1234!', // model cast handles hashing
'email_verified_at' => now(),
'is_active' => true,
]
);
$admin->assignRole('super_admin');
$this->command->info('✅ Super admin created: admin@stpecommerce.com / Admin@1234!');
$this->command->warn(' ⚠ Change the password immediately in production!');
}
}