Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use taggable_type in scopeWithAllTags(*) (#207)
scopeWithAllTags and scopeWithAllTagsOfAnyType does not include the taggable_type which leads to wrong results for the given model. $query = Filter::withAllTagsOfAnyType(['test']); dd($query->toSql(), $query->getBindings()); *scopeWithAllTags* Query before change: select * from `filters` where `filters`.`id` in (select `taggables`.`taggable_id` from `taggables` where `taggables`.`tag_id` = ?) and `filters`.`deleted_at` is null Query after change: select * from `filters` where exists (select * from `tags` inner join `taggables` on `tags`.`id` = `taggables`.`tag_id` where `filters`.`id` = `taggables`.`taggable_id` and `taggables`.`taggable_type` = ? and `tags`.`id` = ?) and `filters`.`deleted_at` is null *scopeWithAllTagsOfAnyType* Query before change: select * from `filters` where `filters`.`id` in (select `taggables`.`taggable_id` from `taggables` where `taggables`.`tag_id` = ?) and `filters`.`deleted_at` is null Query after change: select * from `filters` where exists (select * from `tags` inner join `taggables` on `tags`.`id` = `taggables`.`tag_id` where `filters`.`id` = `taggables`.`taggable_id` and `taggables`.`taggable_type` = ? and `tags`.`id` = ?) and `filters`.`deleted_at` is null
- Loading branch information