public function filterBySearchTerm($term, EloquentBuilder &$query, Field $fieldObject, array $selectedItems, $relatedKeyTable)
    {
        if ($term) {
            $query->where(function ($query) use ($term, $fieldObject) {
                foreach ($fieldObject->getOption('search_fields') as $search) {
                    $query->orWhere($this->db->raw($search), 'LIKE', '%'.$term.'%');
                }
            });

            //exclude the currently-selected items if there are any
            if (count($selectedItems)) {
                $query->whereNotIn($relatedKeyTable, $selectedItems);
            }

            //set up the limits
            $query->take($fieldObject->getOption('num_options') + count($selectedItems));
        }
    }
public function filterBySearchTerm($term, EloquentBuilder &$query, Field $fieldObject, array $selectedItems, $relatedKeyTable)
    {
        if ($term) {
            $query->where(function ($query) use ($term, $fieldObject) {
                foreach ($fieldObject->getOption('search_fields') as $search) {
                    $query->orWhere($this->db->raw($search), 'LIKE', '%'.$term.'%');
                }
            });

            //exclude the currently-selected items if there are any
            if (count($selectedItems)) {
                $query->whereNotIn($relatedKeyTable, $selectedItems);
            }

            //set up the limits
            $query->take($fieldObject->getOption('num_options') + count($selectedItems));
        }
    }
public function filterBySearchTerm ( $ term , EloquentBuilder & $ query , Field $ fieldObject , array $ selectedItems , $ relatedKeyTable ) { if ( $ term ) { $ query -> where ( function ( $ query ) use ( $ term , $ fieldObject ) { foreach ( $ fieldObject -> getOption ( 'search_fields' ) as $ search ) { $ query -> orWhere ( $ this -> db -> raw ( $ search ) , 'LIKE' , '%' . $ term . '%' ) ; } } ) ; //exclude the currently-selected items if there are any if ( count ( $ selectedItems ) ) { $ query -> whereNotIn ( $ relatedKeyTable , $ selectedItems ) ; } //set up the limits $ query -> take ( $ fieldObject -> getOption ( 'num_options' ) + count ( $ selectedItems ) ) ; } }
Filters a relationship options query by a search term.

@param mixed                                  $term
@param \Illuminate\Database\Query\Builder     $query
@param \Frozennode\Administrator\Fields\Field $fieldObject
@param array                                  $selectedItems
@param string                                 $relatedKeyTable
Filters a relationship options query by a search term .