|
|
|
@ -289,7 +289,12 @@ trait ActiveRelationTrait
|
|
|
|
|
$link = array_values($deepViaQuery->link); |
|
|
|
|
} |
|
|
|
|
foreach ($primaryModels as $i => $primaryModel) { |
|
|
|
|
if ($this->multiple && count($link) === 1 && is_array($keys = $primaryModel[reset($link)])) { |
|
|
|
|
$keys = null; |
|
|
|
|
if ($this->multiple && count($link) === 1) { |
|
|
|
|
$primaryModelKey = reset($link); |
|
|
|
|
$keys = isset($primaryModel[$primaryModelKey]) ? $primaryModel[$primaryModelKey] : null; |
|
|
|
|
} |
|
|
|
|
if (is_array($keys)) { |
|
|
|
|
$value = []; |
|
|
|
|
foreach ($keys as $key) { |
|
|
|
|
$key = $this->normalizeModelKey($key); |
|
|
|
@ -523,7 +528,8 @@ trait ActiveRelationTrait
|
|
|
|
|
// single key |
|
|
|
|
$attribute = reset($this->link); |
|
|
|
|
foreach ($models as $model) { |
|
|
|
|
if (($value = $model[$attribute]) !== null) { |
|
|
|
|
$value = isset($model[$attribute]) ? $model[$attribute] : null; |
|
|
|
|
if ($value !== null) { |
|
|
|
|
if (is_array($value)) { |
|
|
|
|
$values = array_merge($values, $value); |
|
|
|
|
} elseif ($value instanceof ArrayExpression && $value->getDimension() === 1) { |
|
|
|
@ -574,13 +580,15 @@ trait ActiveRelationTrait
|
|
|
|
|
/** |
|
|
|
|
* @param ActiveRecordInterface|array $model |
|
|
|
|
* @param array $attributes |
|
|
|
|
* @return string |
|
|
|
|
* @return string|false |
|
|
|
|
*/ |
|
|
|
|
private function getModelKey($model, $attributes) |
|
|
|
|
{ |
|
|
|
|
$key = []; |
|
|
|
|
foreach ($attributes as $attribute) { |
|
|
|
|
$key[] = $this->normalizeModelKey($model[$attribute]); |
|
|
|
|
if (isset($model[$attribute])) { |
|
|
|
|
$key[] = $this->normalizeModelKey($model[$attribute]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (count($key) > 1) { |
|
|
|
|
return serialize($key); |
|
|
|
|