Sunday, January 2, 2022

[FIXED] Column not found: 1054 Unknown column 'orders.deleted_at' in 'where clause'

Issue

In my table i don't have deleted_at column.

But in laravel model in return deleted_at is null in where condition.

Below is my code

public function load($id) {

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

can someone helps me? How to fix this?


Solution

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');'


Answered By - Madhuri Patel

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.