I have a little problem. I have a Cakephp 3.6 project. All work fine, but when I want to delete a record in one controller show my a error.
Cannot commit transaction - rollback() has been already called in the nested transaction Cake\Database\Exception\NestedTransactionRollbackException
Cake\ORM\Table->delete
APP/Controller\NewsController.php, line 131
This is my delete action in NewsController.php
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$news = $this->News->get($id);
if ($this->News->delete($news)) {
$this->Flash->success(__('The news has been deleted.'));
} else {
$this->Flash->error(__('The news could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
And the error is highlighted on if ($this->News->delete($news)) {
What can I do ?