255], [['mobile'], 'string', 'max' => 20], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'name' => '推荐人名称', 'mobile' => '推荐人手机号码', 'status' => '状态[-1:删除;0:禁用;1启用;]', 'created_at' => '创建时间', 'updated_at' => '上次更新数据时间', ]; } public static function setData(array $params) { try { if (!empty($params['id'])) { $model = self::findOne(['id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (empty($model)) throw new \Exception('服务不存在或已删除'); } else { $model = self::findOne(['mobile' => $params['mobile'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } } if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new \Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } }