This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

onefineday
onefineday

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?

maniek35187
maniek35187

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

Tainui
Tainui

@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 ?

maniek35187
maniek35187

You have to create function for every field you want to use this solution.

bree7e
bree7e

You can concatenate value in conditions

field:
    label: Label name
    type: text
    conditions: field like '%' + :value + '%'
oskar.villani40843
oskar.villani40843

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

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.