'ID', 'user_id' => '会员id', 'before_id' => '修改前的上级id', 'after_id' => '修改后的上级id', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * 保存数据 * @param array $params * @return bool|object */ public static function setData(array $params) { try { if (!empty($params['user_id'])) { if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; } } catch (Exception $e) { self::$static_error = $e->getMessage(); return false; } } /** * 关联修改前的直推上级 * @return \yii\db\ActiveQuery */ public function getBeforeParent() { return $this->hasOne(User::class, ['id' => 'before_id']); } /** * 关联修改后的直推上级 * @return \yii\db\ActiveQuery */ public function getAfterParent() { return $this->hasOne(User::class, ['id' => 'after_id']); } }