error('database.boot_failed', ['error' => $e->getMessage()]); http_response_code(500); exit('БД недоступна. Увы'); } // Шорткатик экранирования function h(string $v): string { return htmlspecialchars($v, ENT_QUOTES, 'UTF-8'); } // POST $validationError = null; if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST') { $title = trim((string) ($_POST['title'] ?? '')); $content = trim((string) ($_POST['content'] ?? '')); if ($title === '' || $content === '') { http_response_code(422); $validationError = 'Заполните все поля'; } else { try { \App\Models\Note::create(['title' => $title, 'content' => $content]); } catch (\Throwable $e) { $logger->error('note.create_failed', ['error' => $e->getMessage()]); http_response_code(302); header('Location: /?err=1'); exit; } http_response_code(302); header('Location: /'); exit; } } // ------------------------------------------------------------------------------------------ // $notes = \App\Models\Note::query()->orderByDesc('id')->get(); $pgError = null; $pgVersion = null; try { $row = \App\Database::connection()->selectOne('SELECT version()'); $pgVersion = (string) ($row->version ?? 'unknown'); } catch (\Throwable $e) { $logger->error('database.version_failed', ['error' => $e->getMessage()]); $pgError = $e->getMessage(); } $showErrBanner = ($_GET['err'] ?? '') === '1'; ?> webl — заметки
WebLab · заметки

Новая заметка

Заметки

isEmpty()): ?>

Заметок нет

№ id) ?> created_at) ?>

title) ?>

content) ?>