public static function GETSingle($params, $method, $headers, $id) { $id = Request::requireId($params); $data = Book::getById($id); self::exists($data); self::view(['data' => $data]); }
public static function GETSingle($params, $method, $headers) { $id = Request::requireId($params); $posts = Post::getAll(); array_unshift($posts, []); if ($id == 0 || $id > count($posts) - 1) { throw new \Phramework\Exceptions\NotFoundException('Post not found'); } Phramework::view(['posts' => [$posts[$id]]], 'blog', 'My blog #' . $id); //will load viewers/page/blog.php }