Closed ronvdberkmortel closed 2 years ago
Thanks for noticing! I understand the issue and will take a look at it soon.
Have you, by any chance, had time to look at this issue @pascalbaljet? It would be great addition to the package.
Fixed in v2.6.1.
Perhaps the package already contains a solution to this problem, but I was not able to find it. Say you have a model (e.g. Post) with a relationship to another model (e.g. Author). In this example use case, the relationship field can be null, meaning that a post has no author. First, a simple search query:
Search::add(Post::class, ['title'])->get();
The query above works fine, showing all posts (including posts with no author) and allowing the user to search using the post title column. If we want to add the ability to search on the author's name, we have to add the related model column to the query using the dot notation.
Search::add(Post::class, ['title', 'author.name'])->get();
This query works, but appears to use an inner join behind the scenes. As a result, all posts without an author are excluded from the results. The desired behavior would be to show all posts (when no search query is used) and all matching posts (when a search query is used), including posts that lack an author but where the title is a match to the search query.