12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace common\models;
- use Yii;
- use yii\behaviors\TimestampBehavior;
- /**
- * This is the model class for table "{{%designer}}".
- *
- * @property integer $id
- * @property integer $company
- * @property string $realname
- * @property string $introduction
- * @property integer $created_at
- * @property integer $status
- * @property integer $update_at
- */
- class Designer extends \yii\db\ActiveRecord
- {
- const STATUS_YES = 10; //正常
- const STATUS_NO = 0; //删除
- public static function tableName()
- {
- return '{{%designer}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['company', 'realname', 'introduction'], 'required'],
- [['company', 'created_at', 'status', 'update_at'], 'integer'],
- [['created_at','update_at'], 'default', 'value' => time()],
- [['introduction'], 'string'],
- [['realname'], 'string', 'max' => 32],
- [['status'], 'default', 'value' => self::STATUS_YES],
- [['created_at','update_at'], 'default', 'value' => time()],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'company' => '公司编号',
- 'realname' => '姓名',
- 'introduction' => '简介',
- 'created_at' => 'Created At',
- 'status' => 'Status',
- 'update_at' => 'Update At',
- ];
- }
- 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_DESIGNER,':status'=>ImageSource::STATUS_YES]);
- }
- //相关的样板房、工地
- public function getBuilding(){
- return $this->hasMany(Building::className(),['designer_id'=>'id']);
- }
- }
|