<?php
declare(strict_types=1);

use App\Core\Database;

return function (Database $db): void {
    $methods = [
        ['code' => 'cash',          'name_ar' => 'نقدي',         'name_en' => 'Cash',          'sort_order' => 1],
        ['code' => 'check',         'name_ar' => 'شيك',          'name_en' => 'Check',         'sort_order' => 2],
        ['code' => 'visa',          'name_ar' => 'فيزا / بطاقة', 'name_en' => 'Visa / Card',   'sort_order' => 3],
        ['code' => 'bank_transfer', 'name_ar' => 'تحويل بنكي',   'name_en' => 'Bank Transfer', 'sort_order' => 4],
    ];

    foreach ($methods as $m) {
        $existing = $db->selectOne("SELECT id FROM payment_methods WHERE code = ?", [$m['code']]);
        if ($existing) continue;
        $db->insert('payment_methods', [
            'code'       => $m['code'],
            'name_ar'    => $m['name_ar'],
            'name_en'    => $m['name_en'],
            'is_active'  => 1,
            'sort_order' => $m['sort_order'],
        ]);
    }
};