500], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'operator_user_id' => 'Operator User ID', 'operator_user_type' => 'Operator User Type', 'operator_target_user_id' => 'Operator Target User ID', 'behavior' => 'Behavior', 'desc' => 'Desc', 'extra_info' => 'Extra Info', 'ip' => 'Ip', 'status' => 'Status', 'operation_time' => 'Operation Time', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * @param $params * * @return false|self */ public static function setData($params) { try { $model = new self(); $model->loadDefaultValues(); if (!empty($params['ip'])) { $params['ip'] = ip2long($params['ip']); } if (empty($params['operator_target_user_id'])) { $params['operator_target_user_id'] = $params['operator_user_id']; } if (empty($params['operation_time'])) { $params['operation_time'] = time(); } if (!$model->load($params, '')) { throw new RuntimeException($model->getErrorMessage()); } if (!$model->save()) { throw new RuntimeException($model->getErrorMessage()); } return $model; } catch (Exception $e) { self::$static_error = $e->getMessage(); return false; } } /** * @return ActiveQuery */ public function getUser() { return $this->hasOne(User::class, ['id' => 'operator_target_user_id']); } }