Help needed for overriding search in CrudPanel List #731
-
Hi All Does anyone know how to override the search function? My use-case is: After a lot of testing (using both the php function and the mysql function), using SOUNDEX gives better results, so now I'm trying to work out how to alter the search query so that I can inject the soundex functionality. I've tried using the 'searchLogic' attribute of addColumn but this doesn't seem to give the correct results as it looks like it adds to whatever the existing query is. Hope it makes sense?! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @fronbow, thanks for your question. If you'd like to override the search query completely, then you should have your own ![]() Just copy-paste the method from the original // if a search term was present
if ($search && $search['value'] ?? false) {
// filter the results accordingly
$this->crud->applySearchTerm($search['value']);
} Hope this helps. Cheers! |
Beta Was this translation helpful? Give feedback.
@fronbow you have total control of the
search()
function return.You get the Crud query there but you don't need to use it. So you can do your completely custom query there.
In the end just return the same
$this->crud->getEntriesAsJsonForDatatables($entries, $totalEntryCount, $filteredEntryCount, $start);
I suggest you
dd()
those variables in a "regular" crud panel, to have a better look on what that function receives as input, and you should be able to continue using the crud datatable pag…