type_lookup.rb 416 B

12345678910111213141516171819202122232425
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class TypeLookup < ApplicationModel
  3. def self.by_id(id)
  4. lookup = self.lookup(id: id)
  5. return if !lookup
  6. lookup.name
  7. end
  8. def self.by_name(name)
  9. # lookup
  10. lookup = self.lookup(name: name)
  11. if lookup
  12. return lookup.id
  13. end
  14. # create
  15. lookup = create(
  16. name: name
  17. )
  18. lookup.id
  19. end
  20. end