BadWord.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%bad_word}}".
  6. *
  7. * @property int $id ID
  8. * @property string $bad_word 敏感词
  9. * @property int $type 敏感级别
  10. * @property string $replace_word 换替文字
  11. * @property int $create_time 添加时间
  12. * @property int $list_order 排序
  13. */
  14. class BadWord extends \app\common\models\EActiveRecord
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public static function tableName()
  20. {
  21. return '{{%bad_word}}';
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function rules()
  27. {
  28. return [
  29. [['bad_word','type'], 'required'],
  30. [['type', 'create_time', 'list_order'], 'integer'],
  31. [['bad_word', 'replace_word'], 'string', 'max' => 20],
  32. // [['bad_word'], 'unique'],
  33. ];
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function attributeLabels()
  39. {
  40. return [
  41. 'id' => Yii::t('attr','bad_word.id'),
  42. 'bad_word' => Yii::t('attr','bad_word.bad_word'),
  43. 'type' => Yii::t('attr','bad_word.type'),
  44. 'replace_word' => Yii::t('attr','bad_word.replace_word'),
  45. 'create_time' => Yii::t('attr','bad_word.create_time'),
  46. 'list_order' => Yii::t('attr','bad_word.list_order'),
  47. ];
  48. }
  49. //类型
  50. public static function typeOptions($k=null)
  51. {
  52. $options = array('1'=>'禁止显示(全局)','2'=>'禁止显示(未登录)','3'=>'禁止显示(非会员)','4'=>'禁止搜索(全局)','5'=>'禁止搜索(未登录用户)','6'=>'禁止搜索(非会员)','88'=>'禁止发布(全局)','99'=>'全局替换');
  53. if(is_numeric($k))return $options[$k];
  54. return $options;
  55. }
  56. }