Goal-Calibration/data/seedDb.php
Yisroel Baum 051e44033f
wire user texts routes and update seed
open POST /api/texts and node create endpoints to any
authenticated user; expose new /texts and /texts/{id} pages
plus admin-only GET /api/texts/all. ViewController gains
userTexts and userText methods. seed gives Tanach to the
regular user and adds a second non-admin user.
2026-05-02 21:43:48 +03:00

73 lines
1.6 KiB
PHP

<?php
$texts = [
[
'id' => 0,
'name' => 'Tanach',
'userId' => 1,
],
];
$nodes = [
[
'id' => 0,
'title' => 'Tanach',
'textId' => 0,
'parentNodeId' => null,
],
[
'id' => 1,
'title' => 'Torah',
'textId' => 0,
'parentNodeId' => 0,
],
[
'id' => 2,
'title' => 'Bereishis',
'textId' => 0,
'parentNodeId' => 1,
],
];
// Default credentials:
// admin@example.com / admin1234 (admin)
// user@example.com / password1 (regular user)
// user2@example.com / password2 (second regular user, no texts seeded)
$users = [
[
'id' => 0,
'email' => 'admin@example.com',
'passwordHash' => password_hash('admin1234', PASSWORD_DEFAULT),
'isAdmin' => true,
],
[
'id' => 1,
'email' => 'user@example.com',
'passwordHash' => password_hash('password1', PASSWORD_DEFAULT),
'isAdmin' => false,
],
[
'id' => 2,
'email' => 'user2@example.com',
'passwordHash' => password_hash('password2', PASSWORD_DEFAULT),
'isAdmin' => false,
],
];
$plans = [];
$scheduledNodes = [];
$sessions = [];
$fileDataMap = [
'texts.json' => $texts,
'nodes.json' => $nodes,
'users.json' => $users,
'plans.json' => $plans,
'scheduledNodes.json' => $scheduledNodes,
'sessions.json' => $sessions,
];
foreach ($fileDataMap as $file => $data) {
$path = __DIR__ . "/$file";
file_put_contents($path, json_encode($data, JSON_PRETTY_PRINT));
}