Part on Refactoring Section3 finished
This commit is contained in:
parent
594b8a64fa
commit
672ef6a949
5 changed files with 41 additions and 24 deletions
|
|
@ -5,17 +5,14 @@ $config = require('config.php');
|
|||
$db = new Database($config['database'], $username, $password);
|
||||
|
||||
$heading = "Note";
|
||||
$currentUserId = 1;
|
||||
|
||||
$note = $db->query('select * from notes where id = :id', [
|
||||
'id' => $_GET['id']
|
||||
])->fetch();
|
||||
])->findOrFail();
|
||||
|
||||
authorize(($note['user_id'] === $currentUserId));
|
||||
|
||||
|
||||
if (!$note) {
|
||||
abort();
|
||||
}
|
||||
$currentUserId = 1;
|
||||
if ($note['user_id'] != $currentUserId) {
|
||||
abort(Response::FORBIDDEN);
|
||||
}
|
||||
//dd($notes);
|
||||
require "views/note.view.php";
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@
|
|||
|
||||
$heading = "My Notes";
|
||||
|
||||
$notes = $db->query('select * from notes where user_id = 1')->fetchAll();
|
||||
$notes = $db->query('select * from notes where user_id = 1')->get();
|
||||
//dd($notes);
|
||||
require "views/notes.view.php";
|
||||
Loading…
Add table
Add a link
Reference in a new issue