@@ -40,7 +40,9 @@ discard block |
||
| 40 | 40 | $export_eager = []; |
| 41 | 41 | foreach ($export_fields as $field=>$_title) { |
| 42 | 42 | $parts = explode('.', $field); |
| 43 | - if (count($parts) < 2) continue; |
|
| 43 | + if (count($parts) < 2) { |
|
| 44 | + continue; |
|
| 45 | + } |
|
| 44 | 46 | $main = implode('.', array_slice($parts,0,-1)); |
| 45 | 47 | if (!in_array($main, $eager)) { |
| 46 | 48 | $eager[] = $main; |
@@ -48,7 +50,9 @@ discard block |
||
| 48 | 50 | } |
| 49 | 51 | } |
| 50 | 52 | } |
| 51 | - if ($eager) return $dataList->with($eager); |
|
| 53 | + if ($eager) { |
|
| 54 | + return $dataList->with($eager); |
|
| 55 | + } |
|
| 52 | 56 | return $dataList; |
| 53 | 57 | } |
| 54 | 58 | } |
@@ -13,8 +13,11 @@ |
||
| 13 | 13 | foreach ($arr as $k => $v) { |
| 14 | 14 | $key = $k; |
| 15 | 15 | if ($kfield!==null) { |
| 16 | - if (is_array($v) && isset($v[$kfield])) $key = $v[$kfield]; |
|
| 17 | - elseif (is_object($v) && isset($v->$kfield)) $key = $v->$kfield; |
|
| 16 | + if (is_array($v) && isset($v[$kfield])) { |
|
| 17 | + $key = $v[$kfield]; |
|
| 18 | + } elseif (is_object($v) && isset($v->$kfield)) { |
|
| 19 | + $key = $v->$kfield; |
|
| 20 | + } |
|
| 18 | 21 | } |
| 19 | 22 | $result[$key] = $v; |
| 20 | 23 | } |
@@ -16,7 +16,9 @@ |
||
| 16 | 16 | if (!isset($this->owner->withList)) { |
| 17 | 17 | $this->owner->withList = []; |
| 18 | 18 | } |
| 19 | - if (!is_array($list)) $list = [$list]; |
|
| 19 | + if (!is_array($list)) { |
|
| 20 | + $list = [$list]; |
|
| 21 | + } |
|
| 20 | 22 | $list = array_map(function($e) {return explode('.', $e); }, $list); |
| 21 | 23 | $this->owner->withList = array_merge($this->owner->withList, $list); |
| 22 | 24 | return EagerLoadedDataList::cloneFrom($this->owner); |
@@ -67,7 +67,9 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function prepareEagerRelations() { |
| 70 | - if ($this->relationsPrepared) return; |
|
| 70 | + if ($this->relationsPrepared) { |
|
| 71 | + return; |
|
| 72 | + } |
|
| 71 | 73 | $this->relationsPrepared = true; |
| 72 | 74 | $localClass = $this->dataClass(); |
| 73 | 75 | $config = Config::forClass($localClass); |
@@ -221,7 +223,9 @@ discard block |
||
| 221 | 223 | foreach ($idsQuery as $row) { |
| 222 | 224 | $relID = $row[$component['childField']]; |
| 223 | 225 | $localID = $row[$component['parentField']]; |
| 224 | - if (!isset($collection[$localID])) $collection[$localID] = []; |
|
| 226 | + if (!isset($collection[$localID])) { |
|
| 227 | + $collection[$localID] = []; |
|
| 228 | + } |
|
| 225 | 229 | $collection[$localID][] = $relID; |
| 226 | 230 | $relListReverted[$relID] = 1; //use ids as keys to avoid |
| 227 | 231 | } |