<?php

namespace Database\Seeders;

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

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

        $terminals = [
            ['type' => 'admin', 'name' => '后台', 'description' => '后台管理终端', 'sort' => 1, 'status' => 1],
            ['type' => 'user', 'name' => '用户', 'description' => '前台用户管理终端', 'sort' => 2, 'status' => 1],
            ['type' => 'home', 'name' => '前端', 'description' => '官网前端导航菜单', 'sort' => 3, 'status' => 1],
        ];

        foreach ($terminals as &$terminal) {
            $terminal['create_time'] = $now;
            $terminal['update_time'] = $now;
        }

        foreach ($terminals as $terminal) {
            DB::table('admin_menu_terminals')->updateOrInsert(
                ['type' => $terminal['type']],
                $terminal
            );
        }
    }
}
