customer search

This commit is contained in:
Aung Myo
2017-06-13 20:11:24 +06:30
parent 77a41eb9dc
commit b86ae8d32d
6 changed files with 61 additions and 40 deletions

View File

@@ -34,12 +34,17 @@ class Customer < ApplicationRecord
def self.search(search)
if search
find(:all, :conditions => ['name LIKE ?', "%#{search}%"])
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
else
find(:all)
end
end
# def self.search(search)
# where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
# end
def lastest_invoices
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
end