laravel-pivot-softdeletes
laravel-pivot-softdeletes copied to clipboard
whereHas w/ Addtl Constraints Not Working w/ withTrashedPivots
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