<?php
require_once __DIR__ . '/../config.php';

function seed_categories() {
    $pdo = db();
    $categories = [
        ['name' => 'E-Commerce', 'slug' => 'ecommerce', 'icon_url' => 'shopping-bag'],
        ['name' => 'Food Delivery', 'slug' => 'food', 'icon_url' => 'coffee'],
        ['name' => 'Movie Tickets', 'slug' => 'movies', 'icon_url' => 'film'],
        ['name' => '30-Min Delivery', 'slug' => 'delivery', 'icon_url' => 'truck'],
    ];

    $stmt = $pdo->prepare("INSERT INTO categories (name, slug, icon_url) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE name=VALUES(name)");

    foreach ($categories as $category) {
        $stmt->execute([$category['name'], $category['slug'], $category['icon_url']]);
    }
    echo "Categories seeded successfully." . PHP_EOL;
}

if (basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
    seed_categories();
}
