CakeDC\Users\Controller\Traits\SimpleCrudTrait::delete PHP Method

delete() public method

Delete method
public delete ( string | null $id = null ) : Response
$id string | null User id.
return Cake\Network\Response Redirects to index.
    public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);
        $table = $this->loadModel();
        $tableAlias = $table->alias();
        $entity = $table->get($id, ['contain' => []]);
        $singular = Inflector::singularize(Inflector::humanize($tableAlias));
        if ($table->delete($entity)) {
            $this->Flash->success(__d('CakeDC/Users', 'The {0} has been deleted', $singular));
        } else {
            $this->Flash->error(__d('CakeDC/Users', 'The {0} could not be deleted', $singular));
        }
        return $this->redirect(['action' => 'index']);
    }