laravel-pivot-softdeletes icon indicating copy to clipboard operation
laravel-pivot-softdeletes copied to clipboard

whereHas w/ Addtl Constraints Not Working w/ withTrashedPivots

Open TCURT15 opened this issue 1 year ago • 0 comments


class Post extends Model
{
    public function tags()
    {
        return $this->belongsToMany(Tag::class)->withSoftDeletes()->withTrashedPivots();
    }
}
Post::whereHas('tags'); // works as expected

Post::whereHas('tags', function ($query) {
  $query->where('tags.x', 'y');
}); // does not include trashed pivots

TCURT15 avatar Jun 08 '23 20:06 TCURT15