0
votes

When I try to use soft delete on one of app's model I get Method Illuminate\Database\Query\Builder::onlyTrashed does not exist exception. On user model it is working. They both use SoftDeletes trait.

1

1 Answers

1
votes

I forgot to call parent::boot() in the model's boot method. I think the same problem can occur with model's constructor.

public static function boot()
{
    parent::boot(); //this was missing

    self::creating(function($model) {
        $event = self::orderBy('id', 'desc')->first();
        $model->identifier = $event ? ($event->identifier+1) : 1000;
    });
}