<?php

namespace App\Database\Seeds;

use CodeIgniter\Database\Seeder;

/**
 * Loads bulk Bahrain transport test data (staff, companies, contracts, sites, schedules).
 *
 * Run: php scripts/seed_transport_bulk_data.php
 * Or:  php spark db:seed TransportBulkDataSeeder
 *
 * Idempotent: skips if employee BHST00001 already exists.
 */
class TransportBulkDataSeeder extends Seeder
{
    public function run(): void
    {
        $script = ROOTPATH . 'scripts' . DIRECTORY_SEPARATOR . 'seed_transport_bulk_data.php';

        if (! is_file($script)) {
            echo "Transport bulk seed script not found at {$script}\n";
            return;
        }

        passthru(escapeshellarg(PHP_BINARY) . ' ' . escapeshellarg($script), $exitCode);

        if ($exitCode !== 0) {
            echo "Transport bulk seed script exited with code {$exitCode}\n";
        }
    }
}
