public function show()
 {
     $data = array();
     $blogId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     if ($blogId == 0) {
         header("Location: index.php?c=blog");
     }
     $blogCollection = new BlogCollection();
     $blog = $blogCollection->getOne($blogId);
     if ($blog === null) {
         header("Location: index.php?c=blog");
     }
     $blogImagesCollection = new BlogImagesCollection();
     $blogImages = $blogImagesCollection->getAll(array('blog_post_id' => $blog->getId()));
     $data['blog'] = $blog;
     $data['blogImages'] = $blogImages;
     $this->loadFrontView('blog/show', $data);
 }
 public function deleteBlogImage()
 {
     if (!$this->loggedIn()) {
         header('Location: index.php?c=login&m=login');
     }
     if (!isset($_GET['id'])) {
         header('Location: index.php?c=blog&m=index');
     }
     $imageCollection = new BlogImagesCollection();
     $image = $imageCollection->getOne($_GET['id']);
     if (is_null($image)) {
         header('Location: index.php?c=blog&m=index');
     }
     $tourId = $image->getBlogPostId();
     unlink('uploads/tours/' . $image->getImage());
     $imageCollection->delete($_GET['id']);
     header("Location: index.php?c=blog&m=blogImages&id=" . $tourId);
 }