public function delete($id) { $this->request->allowMethod(['delete']); $employee = $this->Employees->get($id); $message = 'Deleted'; if (!$this->Employees->delete($employee)) { $messge = 'Error'; } $this->set('message', $message); $this->viewBuilder()->setOption('serialize', ['message']); }