TimestampBehavior::class, 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'], ], ], ]; } // 关联用户 public function getUser() { return $this->hasOne(User::className(),['id'=>'user_id']); } // 关联患者 public function getUserPatient() { return $this->hasOne(UserPatient::className(),['id'=>'u_id']); } public function afterFind() { parent::afterFind(); isset($this->created_at) && $this->created_at = date('Y-m-d', $this->created_at); isset($this->updated_at) && $this->updated_at = date('Y-m-d', $this->updated_at); } }