SearchRecord.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace common\models;
  3. use common\behaviors\CommentBehavior;
  4. use common\modules\user\models\User;
  5. use Yii;
  6. use yii\behaviors\BlameableBehavior;
  7. use yii\behaviors\TimestampBehavior;
  8. /**
  9. * This is the model class for table "{{%search_record}}".
  10. *
  11. * @property integer $id
  12. * @property string $keyword
  13. * @property integer $created_at
  14. * @property integer $updated_at
  15. * @property integer $user_id
  16. * @property integer $count
  17. * @property integer $del
  18. */
  19. class SearchRecord extends \yii\db\ActiveRecord
  20. {
  21. /**
  22. * @inheritdoc
  23. */
  24. public static function tableName()
  25. {
  26. return '{{%search_record}}';
  27. }
  28. /**
  29. * @inheritdoc
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['keyword'], 'required'],
  35. [['user_id','count','del'], 'integer'],
  36. [['keyword'], 'string', 'max' => 128],
  37. ];
  38. }
  39. /**
  40. * @inheritdoc
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'keyword' => '关键词',
  47. 'created_at' => 'created_at',
  48. 'updated_at' => 'updated_at',
  49. 'user_id' => '用户',
  50. 'count' => '次数',
  51. 'del' => '是否已删除',
  52. ];
  53. }
  54. public function behaviors()
  55. {
  56. return [
  57. [
  58. 'class' => TimestampBehavior::className(),
  59. ],
  60. [
  61. 'class' => BlameableBehavior::className(),
  62. 'createdByAttribute' => 'user_id',
  63. 'updatedByAttribute' => false,
  64. ],
  65. ];
  66. }
  67. public function getUser()
  68. {
  69. return $this->hasOne(User::className(), ['id' => 'user_id']);
  70. }
  71. }