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.

1-4 of 4