<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        $this->call([
            // PRC-481: PermissionSeeder MUST run before AdminSeeder. It owns
            // the canonical 194-perm admin list (incl. admin.transactions,
            // manage billing rules, view transactions, …). It was never
            // called by DatabaseSeeder, so those 43 perms that exist only
            // here were never created → many admin routes 403'd for everyone
            // (super-admin included). AdminSeeder::createRolesWithPermissions
            // grants super-admin every admin-guard permission, so the perms
            // must exist first. PermissionSeeder's own super-admin tail-sync
            // is role-guarded (skips harmlessly when the role isn't created yet).
            PermissionSeeder::class,
            AdminSeeder::class,
            CurrencySeeder::class,
            LanguageSeeder::class,
            CountryCitySeeder::class,
            ClientGroupSeeder::class,
            // Registrar + TLD catalog MUST be seeded before any seeder that
            // creates ClientDomain rows — the factory picks tld_id from the
            // active TLDs. Previously these ran AFTER DummyClientSeeder, so
            // factory-created domains got tld_id values pointing at rows that
            // didn't exist yet (or pointed at the wrong TLD entirely).
            RegistrarSeeder::class,
            RegistrarSettingSeeder::class,
            TldSeeder::class,
            ClientSeeder::class,
            // PRC-451: Product katalogu (config option grup/option, kategori,
            // ProductSeeder) DummyClientSeeder'dan ÖNCE seed edilmeli — aynı
            // TLD'deki (yukarıdaki) tuzak: DummyClientSeeder ClientProduct
            // factory satırları üretiyor; factory module'ü gerçek product'tan
            // türetiyor. Ürünler yoksa factory 'dummyproduct'a fallback edip
            // server/ssl client_products'ı yanlış family ile seed ediyordu.
            ProductConfigOptionGroupSeeder::class,
            ProductConfigOptionSeeder::class,
            ProductCategorySeeder::class,
            ProductSeeder::class,
            // PRC-840 — whitelabel QA fixture (demo reseller + brand.test);
            // vitrin ProductGroup id'sine bağımlı → ProductSeeder'dan SONRA
            ResellerBrandSeeder::class,
            DummyClientSeeder::class,
            ClientDomainSeeder::class,
            ClientCustomFieldSeeder::class,
            ClientCustomFieldValueSeeder::class,
            ClientProductSeeder::class,
            ServerGroupSeeder::class,
            ServerSeeder::class,
            ServerGroupRelationSeeder::class,
            PricingSeeder::class,
            TicketDepartmentSeeder::class,
            TicketDepartmentTranslationSeeder::class,
            // Departmanlara IMAP/POP3 inbox(ları) bağlar (dev fixture). Her satır
            // kendi credential'ı; password boş satır atlanır. DB'de encrypted cast.
            TicketDepartmentMailboxSeeder::class,
            TicketStatusSeeder::class,
            EscalationRuleSeeder::class,
            TicketPredefinedReplySeeder::class,
            CommunicationTemplateSeeder::class,
            ServiceCostSeeder::class,
            DomainCostSeeder::class,
            ClientBalanceTypeSeeder::class,
            ClientBalanceSeeder::class, // ← Test transaction'ları oluştur
            CouponSeeder::class,
            SettingsSeeder::class,
            SupportSettingsSeeder::class,
            // PRC-554 — Locale-aware URL slug eşleştirmeleri (route_slugs tablosu).
            // LanguageSeeder sonrası çalışmalı (active languages'ı kullanır).
            RouteSlugSeeder::class,
            TaxRuleSeeder::class,
            CancellationRequestSeeder::class,
            LogSeeder::class,
            InvoiceBillingSeeder::class,
            TicketSeeder::class,
            PaymentGatewaySeeder::class,
            // PRC-501: PRC-327 universal-module ailelerini (sms/email/
            // citizenship/dns/currency) `modules` tablosuna kaydeder.
            // DatabaseSeeder pipeline'ına bağlı değildi → fresh install/QA
            // her reset'te boş modules state'ine düşüyordu (PRC-481 ile aynı
            // sınıf gap).
            ModulesSeeder::class,
            TagSeeder::class,
            PostSeeder::class,
            MenuSeeder::class,
            StaticPagesSeeder::class,
            ContractSeeder::class,
            NetworkStatusSeeder::class,
        ]);
    }
}
