where($field, 'LIKE', "%$keyword%"); } else { $query->orWhere($field, 'LIKE', "%$keyword%"); } } }); } /** * Get all searchable fields * * @return array */ public static function getSearchFields() { $model = new static; $fields = $model->search; if (empty($fields)) { $fields = Schema::getColumnListing($model->getTable()); $others[] = $model->primaryKey; $others[] = $model->getUpdatedAtColumn() ?: 'created_at'; $others[] = $model->getCreatedAtColumn() ?: 'updated_at'; $others[] = method_exists($model, 'getDeletedAtColumn') ? $model->getDeletedAtColumn() : 'deleted_at'; $fields = array_diff($fields, $model->getHidden(), $others); } return $fields; } }