<?php
declare(strict_types=1);

use App\Core\Database;

return function (Database $db): void {
    $branches = [
        ['branch_code' => 'sheraton',    'name_ar' => 'فرع شيراتون / مصر الجديدة',    'name_en' => 'Sheraton / Masr El-Gedida',  'phone' => '0222222001'],
        ['branch_code' => 'sadis',       'name_ar' => 'فرع السادس من أكتوبر',         'name_en' => '6th of October',             'phone' => '0222222002'],
        ['branch_code' => 'new_capital', 'name_ar' => 'فرع العاصمة الإدارية الجديدة', 'name_en' => 'New Administrative Capital',  'phone' => '0222222003'],
    ];

    foreach ($branches as $branch) {
        $existing = $db->selectOne("SELECT id FROM branches WHERE branch_code = ?", [$branch['branch_code']]);
        if ($existing) {
            continue;
        }
        $db->insert('branches', [
            'branch_code' => $branch['branch_code'],
            'name_ar'     => $branch['name_ar'],
            'name_en'     => $branch['name_en'],
            'phone'       => $branch['phone'],
            'is_active'   => 1,
            'created_at'  => date('Y-m-d H:i:s'),
            'updated_at'  => date('Y-m-d H:i:s'),
        ]);
    }
};