Get onlyTrashed() does not exist in query builder

Posted 1 year ago by SkyCoder

I am trying to get trashed rows from table messages:

public function trash() {
    return $this->onlyTrashed()
        ->where('user_id', '=', $this->_u)
        ->orWhere('receiver', '=', $this->_u)
        ->orderBy('deleted_at', 'desc')->get();
}

I get this error: Method Illuminate\Database\Query\Builder::onlyTrashed does not exist.

I checked up Builder and SoftDeletes files for onlyTrashed method and it does not exist, how can I look up to trashed messages from message table?

The only way I think about is to create method that doesn't return messages where delete_at is not null and for trashed to return only those where it is not null. But I am still wondering why this doesn't work since it is in documentation at this url:

https://laravel.com/docs/5.6/eloquent#soft-deleting

Please sign in or create an account to participate in this conversation.