@@ -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 | } |
@@ -58,7 +58,9 @@ discard block |
||
| 58 | 58 | private $relationsPrepared = false; |
| 59 | 59 | |
| 60 | 60 | public function prepareEagerRelations() { |
| 61 | - if ($this->relationsPrepared) return; |
|
| 61 | + if ($this->relationsPrepared) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 62 | 64 | $this->relationsPrepared = true; |
| 63 | 65 | $localClass = $this->dataClass(); |
| 64 | 66 | $config = Config::forClass($localClass); |
@@ -206,7 +208,9 @@ discard block |
||
| 206 | 208 | foreach ($idsQuery as $row) { |
| 207 | 209 | $relID = $row[$component['childField']]; |
| 208 | 210 | $localID = $row[$component['parentField']]; |
| 209 | - if (!isset($collection[$localID])) $collection[$localID] = []; |
|
| 211 | + if (!isset($collection[$localID])) { |
|
| 212 | + $collection[$localID] = []; |
|
| 213 | + } |
|
| 210 | 214 | $collection[$localID][] = $relID; |
| 211 | 215 | $relListReverted[$relID] = 1; //use ids as keys to avoid |
| 212 | 216 | } |
@@ -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); |