MedicOneSystems / MedicOneSystems/livewire-datatables
Searchable seems not to work with 'relation.prop:group_concact'
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
Hello !
I have a little problem with the search function, I have a column Type with a ManyToMany relation (and so a pivot table). As mentioned in the documentation, I am able to retrieve the concatenated list of types with : 'types.title:group_concat'
This works perfectly and I can then process this list and display it as I want (here I split the list and process each element individually).
Anyway, my issue is related to the search, I did add the searchable() but unfortunately, it doesn't seem to work and I can't find the entries by typing the title of a type (I tried typing the id of a type, and I even tried typing a count to see if that was what was being search. But it doesn't do anything and this could be a problem, does anyone have an idea how to fix this problem? Did I make a mistake?
I thank you in advance
Column::callback('types.title:group_concat', function ($value) {
$types = preg_split("/,+/", $value, 0);
$result[] ='';
foreach ($types as $i => $type) {
if($i <= 2) {
$result[] = "<span> " . $type . " </span>";
}
}
if(count($types) > 3) {
$hiddenTypes = count($types) - 3;
$result[] = "<span> +" . $hiddenTypes . " </span>";
}
return join('', $result);
})
->searchable()
->unsortable()
->label('Type'),
(Spans are normally stylized, here I removed their classes to improve readability)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the documented types.title:group_concat syntax and the provided searchable() column definition. Trace how searchable relation and callback columns are turned into a search query, then check whether the related type title is included; done means searching by a type title returns the expected entries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- database, search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100