123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace common\models;
- use Yii;
- /**
- * This is the model class for table "{{%reply}}".
- *
- * @property integer $id
- * @property integer $cid
- * @property integer $from_userid
- * @property integer $to_userid
- * @property string $content
- * @property integer $created_at
- * @property integer $status
- */
- class Reply extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- const STATUS_DELETED = 0;
- const STATUS_ACTIVE = 10;
- public static function tableName()
- {
- return '{{%reply}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['cid', 'from_userid', 'to_userid', 'content', 'created_at', 'status'], 'required'],
- [['cid', 'from_userid', 'to_userid', 'created_at', 'status'], 'integer'],
- [['content'], 'string'],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'cid' => 'Cid',
- 'from_userid' => 'From Userid',
- 'to_userid' => 'To Userid',
- 'content' => 'Content',
- 'created_at' => 'Created At',
- 'status' => 'Status',
- ];
- }
- //回复人
- public function getFromuser(){
- return $this->hasOne(User::className(),['id'=>'from_userid']);
- }
- //被回复者
- public function getTouser(){
- return $this->hasOne(User::className(),['id'=>'to_userid']);
- }
- //回复人
- public function getFrom(){
- return $this->hasOne(UserInfo::className(),['uid'=>'from_userid'])->select('uid,nickname');
- }
- //被回复者
- public function getTo(){
- return $this->hasOne(UserInfo::className(),['uid'=>'to_userid'])->select('uid,nickname');
- }
- //回复人
- public function getFro(){
- return $this->hasOne(UserCompany::className(),['uid'=>'from_userid'])->select('uid,company');
- }
- //被回复者
- public function getToo(){
- return $this->hasOne(UserCompany::className(),['uid'=>'to_userid'])->select('uid,company');
- }
- }
|