Category.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace fecshop\models\mongodb;
  3. use yii\mongodb\ActiveRecord;
  4. class Category extends ActiveRecord
  5. {
  6. const MENU_SHOW = 1;
  7. const MENU_NOT_SHOW = 2;
  8. const STATUS_ENABLE = 1;
  9. const STATUS_DISABLE = 2;
  10. /**
  11. * mongodb collection 的名字,相当于mysql的table name
  12. */
  13. public static function collectionName()
  14. {
  15. return 'category';
  16. }
  17. /**
  18. * mongodb是没有表结构的,因此不能像mysql那样取出来表结构的字段作为model的属性
  19. * 因此,需要自己定义model的属性,下面的方法就是这个作用
  20. */
  21. public function attributes()
  22. {
  23. return [
  24. '_id',
  25. 'parent_id',
  26. 'name',
  27. 'status',
  28. 'menu_show',
  29. 'url_key',
  30. 'level',
  31. 'thumbnail_image',
  32. 'image',
  33. 'filter_product_attr_selected',
  34. 'filter_product_attr_unselected',
  35. 'description',
  36. 'menu_custom',
  37. 'title',
  38. 'meta_description',
  39. 'meta_keywords',
  40. 'include_in_menu',
  41. 'is_feature',
  42. 'available_sort_by',
  43. 'default_sort_by',
  44. 'theme',
  45. 'active_from',
  46. 'active_to',
  47. 'created_at',
  48. 'updated_at',
  49. 'created_user_id',
  50. //other
  51. /*
  52. category filter
  53. category product
  54. */
  55. ];
  56. }
  57. }