true, 'targetClass' => User::className(), 'targetAttribute' => ['created_by' => 'id']], [['webboard_post_id'], 'exist', 'skipOnError' => true, 'targetClass' => WebboardPost::className(), 'targetAttribute' => ['webboard_post_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'webboard_post_id' => 'กระทู้', 'name' => 'ตอบกระทู้', 'created_at' => 'เพิ่มเมื่อ', 'created_by' => 'เพิ่มโดย', 'updated_at' => 'แก้ไขเมื่อ', 'updated_by' => 'แก้ไขโดย', ]; } /** * @return \yii\db\ActiveQuery */ public function getCreatedBy() { return $this->hasOne(User::className(), ['id' => 'created_by']); } public function getUpdatedBy() { return $this->hasOne(User::className(), ['id' => 'updated_by']); } /** * @return \yii\db\ActiveQuery */ public function getWebboardPost() { return $this->hasOne(WebboardPost::className(), ['id' => 'webboard_post_id']); } }