G
G
ganjo8882020-02-20 16:02:03
Laravel
ganjo888, 2020-02-20 16:02:03

Why does withTrashed not exist?

My code

public function restore($params)
    {
      return  User::withTrashed()->find(6)->restore();
    }

my model
class User extends Model
{
    use SnakeCaseToCamelCaseTrait, SoftDeletes;

    protected $table = 'users';
    protected $guarded = ['id'];
    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
}

Error
"Method Illuminate\\Database\\Query\\Builder::withTrashed does not exist."

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question