Codeigniter 4 软删除仍在删除数据库记录

Codeigniter 4 Soft Delete Still Deleting DB Record

我对 CodeIgniter 4 软删除有疑问。 我在模型中设置了 $useSoftDelete = true;但是每当我删除一条记录时,删除方法总是从我的 table.

中清除它

这是我模型中的代码:

    // Dates
protected $useTimestamps        = true;
protected $useSoftDelete        = true;
protected $dateFormat           = 'datetime';
protected $createdField         = 'cust_created_at';
protected $updatedField         = 'cust_updated_at';
protected $deletedField         = 'cust_deleted_at';

这是我在控制器中的删除方法:

public function delete($id = '')
{
    $customer = $this->customerModel->find($id);
    if (isset($customer)) {
        $this->customerModel->delete($id);
        session()->setFlashdata('success', "Customer $customer->cust_name successfully deleted.");
        return redirect()->to(site_url('customer'));
    } else {
        session()->setFlashdata('errors', ["Cannot find customer ID $id."]);
        return redirect()->to(site_url('customer'));
    }
}

我错过了什么代码吗? 提前谢谢你。

输入错误
protected $useSoftDelete = true;.
应该是
protected $useSoftDeletes = true;

参考: https://codeigniter4.github.io/userguide/models/model.html#configuring-your-model