未找到列:“where 子句”中的 1054 列“orders.deleted_at”未知

Mal*_*ndo 0 soft-delete laravel eloquent laravel-5

在我的表中,我没有 delete_at 列。

但在 Laravel 模型中,在 where 条件下,deleted_at 返回 null。

下面是我的代码

public function load($id) {

        return $this
            ->select(sprintf('%s.*', $this->getTable()))
            ->where(sprintf('%s.id', $this->getTable(), $this->getKeyName()), '=', $id)
            ->first();
    }
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我吗?如何解决这个问题?

Mad*_*tel 10

您必须use SoftDeletes;从模型文件中删除特征。

然后使用以下代码:

 return $this->where(sprintf('%s.id', $this->getTable(), $this->getKeyName()), '=', $id)
        ->pluck('id');'
Run Code Online (Sandbox Code Playgroud)