<?php

namespace Database\Seeders;

use App\Models\Module;
use Illuminate\Database\Seeder;

class ModulesCatalogSeeder extends Seeder
{
    public function run(): void
    {
        $catalog = config('modules.modules');

        $sort = 0;
        foreach ($catalog as $key => $data) {
            Module::updateOrCreate(
                ['key' => $key],
                [
                    'name'        => $data['name'],
                    'group'       => $data['group'],
                    'is_core'     => $data['core'] ?? false,
                    'sort_order'  => $sort++,
                ]
            );
        }
    }
}
