Nav.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%nav}}".
  6. *
  7. * @property int $id ID
  8. * @property int $parent_id 父级
  9. * @property string $title 标题
  10. * @property string|null $url 链接
  11. * @property string $iconfont 字体图标
  12. * @property int $type 类型
  13. * @property int $blank 新窗口打开
  14. * @property int $is_dropdown 下拉菜单
  15. * @property int $dropdown_level 下拉层级
  16. * @property int $content_model_id 内容模型
  17. * @property int $is_system 系统自带
  18. * @property int|null $disabled 禁用
  19. * @property int|null $list_order 排序
  20. */
  21. class Nav extends \app\common\models\EActiveRecord
  22. {
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public static function tableName()
  27. {
  28. return '{{%nav}}';
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function rules()
  34. {
  35. return [
  36. [['parent_id', 'type', 'blank', 'is_dropdown', 'dropdown_level', 'content_model_id', 'width', 'is_system', 'disabled', 'list_order'], 'integer'],
  37. [['title'], 'required'],
  38. [['title'], 'string', 'max' => 30],
  39. [['url'], 'string', 'max' => 200],
  40. [['iconfont'], 'string', 'max' => 500],
  41. ];
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function attributeLabels()
  47. {
  48. return [
  49. 'id' => Yii::t('attr','nav.id'),
  50. 'parent_id' => Yii::t('attr','nav.parent_id'),
  51. 'title' => Yii::t('attr','nav.title'),
  52. 'url' => Yii::t('attr','nav.url'),
  53. 'iconfont' => Yii::t('attr','nav.iconfont'),
  54. 'type' => Yii::t('attr','nav.type'),
  55. 'blank' => Yii::t('attr','nav.blank'),
  56. 'is_dropdown' => Yii::t('attr','nav.is_dropdown'),
  57. 'dropdown_level' => Yii::t('attr','nav.dropdown_level'),
  58. 'content_model_id' => Yii::t('attr','nav.content_model_id'),
  59. 'width' => Yii::t('attr','nav.width'),
  60. 'is_system' => Yii::t('attr','nav.is_system'),
  61. 'is_new' => Yii::t('attr','nav.is_new'),
  62. 'is_hot' => Yii::t('attr','nav.is_hot'),
  63. 'disabled' => Yii::t('attr','nav.disabled'),
  64. 'list_order' => Yii::t('attr','nav.list_order'),
  65. ];
  66. }
  67. //导航类型
  68. public static function typeOptions($k=null)
  69. {
  70. $options = array('1'=>'PC站首页','2'=>'PC站内页','3'=>'PC站用户中心','4'=>'PC站底部链接','5'=>'PC站首页推荐链接','6'=>'手机站底部导航','7'=>'手机站首页菜单');
  71. if(Yii::$app->getModule('web')->bdappconfig['open'])
  72. {
  73. $options['81'] = '百度小程序首页菜单';
  74. }
  75. if(Yii::$app->getModule('web')->wxappconfig['open'])
  76. {
  77. $options['91'] = '微信小程序首页菜单';
  78. }
  79. if(is_numeric($k))return $options[$k];
  80. return $options;
  81. }
  82. }