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); }