protected $_order = false;
protected $_allows_null = false;
+
public function getDefaultAttributes()
{
- return array_merge(parent::getDefaultAttributes(), ['order' => $this->_order, 'allows_null' => $this->_allows_null]);
+ $field = $this;
+
+ return array_merge(parent::getDefaultAttributes(), [
+ 'order' => $this->_order,
+ 'allows_null' => $this->_allows_null,
+ 'searchLogic' => function ($query, $column, $searchTerm) use ($field) {
+ $pluckAttr = $field->getAttribute('column_attribute', $field->getAttribute('attribute'));
+ $list = $field->pluck($pluckAttr);
+ $findIds = [];
+ foreach ($list as $id => $value) {
+ if (stristr($value, $searchTerm)) {
+ $findIds[] = $id;
+ }
+ }
+ $query->orWhereIn($field->getName(), $findIds);
+ },
+ ]
+ );
}
protected function _preGetDefinition()