Skip to content

Commit 622987e

Browse files
committed
working after base_path and view
1 parent 010a951 commit 622987e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

controllers/notes/create.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
$config = require(base_path('config.php'));
66
$db = new Database($config['database']);
77

8-
$heading = 'Create Note';
8+
// $heading = 'Create Note';
9+
$errors = [];
910

1011
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
11-
$errors = [];
1212

1313
if (! Validator::string($_POST['body'], 1, 1000)) {
1414
$errors['body'] = 'A body of no more than 1000 characters is required.';
@@ -23,4 +23,8 @@
2323
}
2424
}
2525

26-
require base_path('views/notes/create.view.php');
26+
// require base_path('views/notes/create.view.php');
27+
view('notes/create.view.php', [
28+
'heading' => 'Create Note',
29+
'errors' => $errors
30+
]);

controllers/notes/show.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$config = require(base_path('config.php'));
44
$db = new Database($config['database']);
55

6-
$heading = 'Note';
6+
// $heading = 'Note';
77
$currentUserId = 5;
88

99
$note = $db->query('SELECT * FROM notes where id = :id', [
@@ -13,8 +13,11 @@
1313

1414
authorize($note['user_id'] === $currentUserId);
1515

16-
include base_path('views/notes/show.view.php');
17-
16+
// include base_path('views/notes/show.view.php');
17+
view('notes/show.view.php', [
18+
'heading' => 'Note',
19+
'note' => $note
20+
]);
1821

1922
// both is acceptable with : and without : no difference
2023
// $notes = $db->query('SELECT * FROM notes where id = :id', ['id' => $id])->fetch();

0 commit comments

Comments
 (0)