latest Aston req from OPT team

This commit is contained in:
phyusin
2018-03-21 17:45:55 +06:30
parent 0390d15e0a
commit 7063d937e3
8 changed files with 143 additions and 6 deletions

View File

@@ -1,2 +1,17 @@
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("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ?", from,to)
query = survey.where(keyword)
else
where("dining_name LIKE ?", "%#{filter}%")
end
end
end