66 lines
2.5 KiB
PHP
66 lines
2.5 KiB
PHP
<?php
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
function seed_customers() {
|
|
$pdo = db();
|
|
$customers = [
|
|
['name' => 'John Doe', 'email' => 'john.doe@example.com', 'plan' => 'Premium HD', 'status' => 'Active'],
|
|
['name' => 'Jane Smith', 'email' => 'jane.smith@example.com', 'plan' => 'Basic', 'status' => 'Active'],
|
|
['name' => 'Mike Johnson', 'email' => 'mike.j@example.com', 'plan' => 'Premium HD', 'status' => 'Suspended'],
|
|
['name' => 'Sarah Williams', 'email' => 'sarah.w@example.com', 'plan' => 'Family Pack', 'status' => 'Deactivated'],
|
|
];
|
|
|
|
$stmt = $pdo->prepare("INSERT INTO customers (name, email, plan, status) VALUES (:name, :email, :plan, :status) ON DUPLICATE KEY UPDATE name=VALUES(name), plan=VALUES(plan), status=VALUES(status)");
|
|
|
|
foreach ($customers as $customer) {
|
|
echo "Seeding customer: " . $customer['name'] . "...\n";
|
|
try {
|
|
$stmt->execute($customer);
|
|
echo "Success.\n";
|
|
} catch (PDOException $e) {
|
|
echo "Error seeding customer " . $customer['name'] . ": " . $e->getMessage() . "\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
function seed_plans() {
|
|
$pdo = db();
|
|
$plans = [
|
|
[
|
|
'name' => 'Basic Cable',
|
|
'price' => 29.99,
|
|
'billing_cycle' => 'monthly',
|
|
'features' => json_encode(['50+ Channels', 'Standard Definition', '1 TV Connection'])
|
|
],
|
|
[
|
|
'name' => 'Premium HD',
|
|
'price' => 49.99,
|
|
'billing_cycle' => 'monthly',
|
|
'features' => json_encode(['150+ Channels', 'High Definition', 'Includes Sports Pack', '2 TV Connections'])
|
|
],
|
|
[
|
|
'name' => 'Ultimate Fiber',
|
|
'price' => 79.99,
|
|
'billing_cycle' => 'monthly',
|
|
'features' => json_encode(['300+ Channels', '4K Ultra HD', 'All Premium Channels', 'Up to 5 TV Connections', 'On-Demand Library'])
|
|
],
|
|
];
|
|
|
|
$stmt = $pdo->prepare("INSERT INTO plans (name, price, billing_cycle, features) VALUES (:name, :price, :billing_cycle, :features) ON DUPLICATE KEY UPDATE name=VALUES(name), price=VALUES(price), billing_cycle=VALUES(billing_cycle), features=VALUES(features)");
|
|
|
|
foreach ($plans as $plan) {
|
|
echo "Seeding plan: " . $plan['name'] . "...\n";
|
|
try {
|
|
$stmt->execute($plan);
|
|
echo "Success.\n";
|
|
} catch (PDOException $e) {
|
|
echo "Error seeding plan " . $plan['name'] . ": " . $e->getMessage() . "\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
seed_customers();
|
|
seed_plans();
|
|
|
|
|