18 lines
398 B
Ruby
18 lines
398 B
Ruby
class Survey < ApplicationRecord
|
|
|
|
def self.search(filter,from,to)
|
|
if filter.blank?
|
|
keyword = ''
|
|
else
|
|
keyword = "dining_name LIKE ?","%#{filter}%"
|
|
end
|
|
|
|
if from.present? && to.present?
|
|
survey = Survey.where("created_at BETWEEN ? AND ?", from, to)
|
|
query = survey.where(keyword)
|
|
else
|
|
where("dining_name LIKE ?", "%#{filter}%")
|
|
end
|
|
end
|
|
end
|