Reply.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%reply}}".
  6. *
  7. * @property integer $id
  8. * @property integer $cid
  9. * @property integer $from_userid
  10. * @property integer $to_userid
  11. * @property string $content
  12. * @property integer $created_at
  13. * @property integer $status
  14. */
  15. class Reply extends \yii\db\ActiveRecord
  16. {
  17. /**
  18. * @inheritdoc
  19. */
  20. const STATUS_DELETED = 0;
  21. const STATUS_ACTIVE = 10;
  22. public static function tableName()
  23. {
  24. return '{{%reply}}';
  25. }
  26. /**
  27. * @inheritdoc
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['cid', 'from_userid', 'to_userid', 'content', 'created_at', 'status'], 'required'],
  33. [['cid', 'from_userid', 'to_userid', 'created_at', 'status'], 'integer'],
  34. [['content'], 'string'],
  35. ];
  36. }
  37. /**
  38. * @inheritdoc
  39. */
  40. public function attributeLabels()
  41. {
  42. return [
  43. 'id' => 'ID',
  44. 'cid' => 'Cid',
  45. 'from_userid' => 'From Userid',
  46. 'to_userid' => 'To Userid',
  47. 'content' => 'Content',
  48. 'created_at' => 'Created At',
  49. 'status' => 'Status',
  50. ];
  51. }
  52. //回复人
  53. public function getFromuser(){
  54. return $this->hasOne(User::className(),['id'=>'from_userid']);
  55. }
  56. //被回复者
  57. public function getTouser(){
  58. return $this->hasOne(User::className(),['id'=>'to_userid']);
  59. }
  60. //回复人
  61. public function getFrom(){
  62. return $this->hasOne(UserInfo::className(),['uid'=>'from_userid'])->select('uid,nickname');
  63. }
  64. //被回复者
  65. public function getTo(){
  66. return $this->hasOne(UserInfo::className(),['uid'=>'to_userid'])->select('uid,nickname');
  67. }
  68. //回复人
  69. public function getFro(){
  70. return $this->hasOne(UserCompany::className(),['uid'=>'from_userid'])->select('uid,company');
  71. }
  72. //被回复者
  73. public function getToo(){
  74. return $this->hasOne(UserCompany::className(),['uid'=>'to_userid'])->select('uid,company');
  75. }
  76. }