123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace common\models;
- use Yii;
- /**
- * This is the model class for table "{{%manager}}".
- *
- * @property string $id
- * @property integer $company
- * @property string $realname
- * @property string $introduction
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $status
- */
- class Manager extends \yii\db\ActiveRecord
- {
- const STATUS_YES = 10; //正常
- const STATUS_NO = 0; //删除
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%manager}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['company', 'realname', 'introduction'], 'required'],
- [['created_at','updated_at'], 'default', 'value' => time()],
- [['company', 'created_at', 'updated_at', 'status'], 'integer'],
- [['realname'], 'string', 'max' => 32],
- [['introduction'], 'string', 'max' => 255],
- [['status'], 'default', 'value' => self::STATUS_YES],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'company' => '公司ID',
- 'realname' => '名称',
- 'introduction' => '简介',
- 'created_at' => '创建时间',
- 'updated_at' => 'Updated At',
- 'status' => '状态',
- ];
- }
- public function getUser(){
- return $this->hasOne(User::className(),['id'=>'company']);
- }
- // public function getCompanyInfo(){
- // return $this->hasOne(UserCompany::className(),['id'=>'company']);
- // }
- public function getImage(){
- return $this->hasOne(ImageSource::className(),['topid'=>'id'])->where('type=:type AND status = :status',[':type'=>ImageSource::TYPE_MANAGER,':status'=>ImageSource::STATUS_YES]);
- }
- //相关的样板房、工地
- public function getBuilding(){
- return $this->hasMany(Building::className(),['manager_id'=>'id']);
- }
- }
|