public function delete()
    {
        if (!userHasPermission('admin:blog:blog:delete')) {

            unauthorised();
        }

        // --------------------------------------------------------------------------

        $blog = $this->blog_model->getById($this->uri->segment(5));

        if (empty($blog)) {

            $this->session->set_flashdata('error', 'You specified an invalid Blog ID.');
            redirect('admin/blog/blog/index');
        }

        // --------------------------------------------------------------------------

        if ($this->blog_model->delete($blog->id)) {

            $this->session->set_flashdata('success', 'Blog was deleted successfully.');

        } else {

            $this->session->set_flashdata('error', 'Failed to delete blog. ' . $this->blog_model->lastError());
        }

        redirect('admin/blog/blog/index');
    }