In my table i don't have deleted_at column but the Laravel query always checks if deleted_at
is null
, resulting in this error message:
Column not found: 1054 Unknown column 'orders.deleted_at' in 'where clause'
Below is my code
public function load($id) {
return $this
->select(sprintf('%s.*', $this->getTable()))
->where(sprintf('%s.%s', $this->getTable(), $this->getKeyName()), '=', $id)
->first();
}
How to fix this?
You have to remove the traits use SoftDeletes;
from your model file.
and then use below code:
return $this->where(sprintf('%s.id', $this->getTable(), $this->getKeyName()), '=', $id)
->pluck('id');'