public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);

        $category = $this->PostsCategories->get($id);

        //Before deleting, it checks if the category has some posts
        if (!$category->post_count) {
            $this->PostsCategories->deleteOrFail($category);
            $this->Flash->success(I18N_OPERATION_OK);
        } else {
            $this->Flash->alert(I18N_BEFORE_DELETE);
        }

        return $this->redirect(['action' => 'index']);
    }