I have a question for the searchWhere() method in October. How would one search repeater fields if it only searches by column? Is there another method to find this data?
I’m using this in twig, and I want to search the repeater blocks that I have in Tailor, but I don’t see any documentation on the twig function. I should note that I don’t want to use a collection for this. It needs to be paginated.
Is the repeater field stored in long json string? searchWhere should be working with that most probably.
Since you know the json repeater structure in advance, there is also the possibility to use whereJsonContains like this ::whereJsonContains('destinations',["Goa"])->get()
I ended up going a different route. I created a foreach loop to query the content. I also used searchWhere to get the initial page ids to make sure it’s correct
{% set matchingContent = collect() %}
{% set matchingPages = pages.searchWhere(searchTerms.term, ['title', 'content']) %}
{% for page in matchingPages.get() %}
{% if page.id not in matchingContent %}
{% do matchingContent.push(page.id) %}
{% endif %}
{% endfor %}
{% for page in pages.get() %}
{% for section in page.builder %}
{% if searchTerms.term|lower in section.content|lower %}
{% if page.id not in matchingContent %}
{% do matchingContent.push(page.id) %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
I can see the only downside to using this is trying to parse json data. in the orWhereReleation method, I can, but it’s case sensitive and doesn’t allow you to lowercase the the value
EDIT: Nevermind, Saw how the function works and it works beautifully