Closed grafxflow closed 5 years ago
Hi @grafxflow ,
can you try something like this temporarily?
Create an array with possible concat fields and check the $value->name
is present in the array or not.
If it is present in the array, then do concat search else do normal search.
$concatFields = ["first_name","extrafield1","extrafield2"];
// Check for basic text search
foreach ($objectMode->filters as $key => $value) {
if($value->type === 'simple'){
if(in_array($value->name,$concatFields)) {
$query->whereRaw("(CONCAT(first_name, ' ', last_name) LIKE "%{$value->text}%");
// Or if its possible after the Select CONCAT
// where (CONCAT)username LIKE %{$value->text}%"
$query->where($value->name, 'LIKE', "%{$value->text}%");
} else {
$query->where($value->name, 'LIKE', "%{$value->text}%");
}
}
}
But I will try to add more information with the filter object to identify the fields more uniquely. May be i will add the column slot name along with the filter object.
Cheers, Ruby.
Hi @rubanraj54,
Thanks for the reply, it's pointed me in the right direction :)
cheers grafxflow
Glad that it helped you.
Cheers, Ruby.
I am trying to do an automated column query in Laravel which looks like below.
Now this works fine for things like Firstname and Lastname which are actual columns in the database, but I want to CONCAT them in the output table and query this as well. It causes a problem due to the column name not existing in the database because it's a custom name.
Can I add a custom filter name instead of simply.
And then do a database query like...
Currently not using 'simple' in the filter disables/hides the input option. Or is there a way I can manually enable the search input no matter what the filter type?
Or maybe add 2 values and explode the comma and concat + like that way?