<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class AdminRoleSeeder extends Seeder
{
    public function run(): void
    {
        $now = now();

        $roles = [
            [
                'id' => 1,
                'name' => '超级管理员',
                'code' => 'super_admin',
                'description' => '拥有所有权限',
                'parent_id' => null,
                'sort' => 0,
                'status' => 1,
                'create_time' => $now,
                'update_time' => $now,
            ],
            [
                'id' => 2,
                'name' => '普通管理员',
                'code' => 'admin',
                'description' => '基础管理权限',
                'parent_id' => 1,
                'sort' => 1,
                'status' => 1,
                'create_time' => $now,
                'update_time' => $now,
            ],
        ];

        foreach ($roles as $role) {
            DB::table('admin_roles')->updateOrInsert(
                ['code' => $role['code']],
                $role
            );
        }
    }
}
