This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I need to search or filter a backend list of contacts according to a number of search criteria e.g. contacts who have a payment method of "xxx" and who have an address like '%street name%". How can I achieve this please?
I didn't found the solution neither. Configuration like this doesn't work:
field:
label: Label name
type: text
scope: field like '%:filterered%'
You can workaround this adding search scope:
field:
label: Label name
type: text
scope: fieldFilter
In your model:
public function scopeFieldFilter($query, $val)
{
id = FieldModel::where('name','LIKE','%'.$val.'%')->lists('id');
return $query->whereIn('id', $id);
}
Last updated
@maniek35187 : thanks for the reply ; do you know if there a way to retrieve field name into scopeFieldFilter function so it can be used to search into different fields ?
You can concatenate value in conditions
field:
label: Label name
type: text
conditions: field like '%' + :value + '%'
Hi,
conditions: field like '%' + :value + '%'
did not work for me, instead I found
conditions: field like concat('%', :value, '%')
does the job!
best regards :)
1-6 of 6