Merge branch 'adminbsb_material_ui'
This commit is contained in:
@@ -33,27 +33,20 @@ class Menu < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.to_csv
|
||||
m_attributes = %w{id name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at}
|
||||
m_attributes = %w{name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at}
|
||||
CSV.generate(headers: true) do |csv|
|
||||
csv << m_attributes
|
||||
menu = Menu.all
|
||||
menu.each do |user|
|
||||
puts user
|
||||
csv << m_attributes.map{ |attr| user.send(attr)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at}
|
||||
# CSV.generate(headers: true) do |csv|
|
||||
# csv << m_attributes
|
||||
|
||||
# csv << mc_attributes
|
||||
# MenuCategory.all.each do |user|
|
||||
# puts user
|
||||
# csv << mc_attributes.map{ |attr| user.send(attr)}
|
||||
# end
|
||||
# end
|
||||
|
||||
def self.import(file)
|
||||
CSV.foreach(file.path, headers:true) do |row|
|
||||
Menu.create! row.to_hash
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
class MenuCategory < ApplicationRecord
|
||||
# before_create :generate_menu_category_code
|
||||
|
||||
belongs_to :menu
|
||||
belongs_to :menu , counter_cache: true
|
||||
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
|
||||
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
|
||||
has_many :menu_items
|
||||
@@ -83,4 +83,19 @@ class MenuCategory < ApplicationRecord
|
||||
# def generate_menu_category_code
|
||||
# self.code = SeedGenerator.generate_code(self.class.name, "C")
|
||||
# end
|
||||
|
||||
def self.to_csv
|
||||
|
||||
mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at}
|
||||
CSV.generate(headers: true) do |csv|
|
||||
csv << mc_attributes
|
||||
|
||||
csv << mc_attributes
|
||||
MenuCategory.all.each do |user|
|
||||
puts user
|
||||
csv << mc_attributes.map{ |attr| user.send(attr)}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,8 @@ class OrderItem < ApplicationRecord
|
||||
before_create :generate_custom_id
|
||||
|
||||
#Associations
|
||||
belongs_to :order, autosave: true
|
||||
belongs_to :order, autosave: true
|
||||
# belongs_to :order, counter_cache: true
|
||||
|
||||
#Validation
|
||||
validates_presence_of :item_code, :item_name, :qty
|
||||
|
||||
Reference in New Issue
Block a user