<?php

namespace Database\Seeders;

use App\Models\Role;
use App\Services\Permission\PermissionRegistry;
use Illuminate\Database\Seeder;

class RoleAndPermissionSeeder extends Seeder
{
    public function run(): void
    {
        $registry = app(PermissionRegistry::class);
        $permissions = $registry->syncConfiguredPermissions();

        $superAdmin = Role::findOrCreate(
            config('permissions.super_admin_role', 'Super Admin'),
            config('permissions.guard', 'web')
        );

        $superAdmin->syncPermissions($permissions);

        Role::findOrCreate(
            config('permissions.customer_role', 'Customer'),
            config('permissions.guard', 'web')
        );
    }
}
