初始化
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AdminUserSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// 用 updateOrCreate 而非 firstOrCreate:若账号已存在(如早期测试注册过、
|
||||
// 或旧版种子先建过且 role=user),仍需强制校正为超管并重置密码,避免「找到了就不更新」导致无后台权限。
|
||||
User::updateOrCreate(
|
||||
['email' => 'admin@cloud-chip.cn'],
|
||||
[
|
||||
'name' => '管理员',
|
||||
'email' => 'admin@cloud-chip.cn',
|
||||
'password' => 'cloudchip2026',
|
||||
'is_admin' => true,
|
||||
'role' => 'super_admin',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user