<?php
$pdo = require __DIR__ . '/config/pdo.php';

$sliders = [
    ['banner1.png', 'Oleh-oleh Premium', 'Koleksi lengkap untuk menyempurnakan ibadah Anda.', 'public/index.php?page=products'],
    ['banner2.png', 'Kurma Ajwa & Zamzam', 'Langsung dari tanah suci, dijamin keasliannya.', 'public/index.php?page=products&q=kurma'],
    ['banner3.png', 'Paket Hadiah Spesial', 'Cocok untuk kado kerabat dan keluarga.', 'public/index.php?page=products']
];

foreach ($sliders as $index => $s) {
    // Check if image exists in uploads, if not copy from assets
    $source = __DIR__ . '/assets/img/' . $s[0];
    $dest = __DIR__ . '/uploads/' . $s[0];
    if (file_exists($source) && !file_exists($dest)) {
        copy($source, $dest);
    }
    
    $sort = $index;
    $sql = "INSERT INTO sliders (image, title, description, link_url, sort_order) VALUES (?, ?, ?, ?, ?)";
    $pdo->prepare($sql)->execute([$s[0], $s[1], $s[2], $s[3], $sort]);
}
echo "Default sliders seeded!";
