| @@ 250-264 (lines=15) @@ | ||
| 247 | * @param EntityCollection $results |
|
| 248 | * @return array |
|
| 249 | */ |
|
| 250 | protected function buildDictionary(EntityCollection $results) |
|
| 251 | { |
|
| 252 | $dictionary = []; |
|
| 253 | ||
| 254 | $foreign = $this->getPlainForeignKey(); |
|
| 255 | ||
| 256 | // First we will create a dictionary of models keyed by the foreign key of the |
|
| 257 | // relationship as this will allow us to quickly access all of the related |
|
| 258 | // models without having to do nested looping which will be quite slow. |
|
| 259 | foreach ($results as $result) { |
|
| 260 | $dictionary[$result->{$foreign}][] = $result; |
|
| 261 | } |
|
| 262 | ||
| 263 | return $dictionary; |
|
| 264 | } |
|
| 265 | ||
| 266 | /** |
|
| 267 | * Get the key for comparing against the parent key in "has" query. |
|
| @@ 206-220 (lines=15) @@ | ||
| 203 | * @param EntityCollection $results |
|
| 204 | * @return array |
|
| 205 | */ |
|
| 206 | protected function buildDictionary(EntityCollection $results) |
|
| 207 | { |
|
| 208 | $dictionary = []; |
|
| 209 | ||
| 210 | $foreign = $this->firstKey; |
|
| 211 | ||
| 212 | // First we will create a dictionary of entities keyed by the foreign key of the |
|
| 213 | // relationship as this will allow us to quickly access all of the related |
|
| 214 | // entities without having to do nested looping which will be quite slow. |
|
| 215 | foreach ($results as $result) { |
|
| 216 | $dictionary[$result->{$foreign}][] = $result; |
|
| 217 | } |
|
| 218 | ||
| 219 | return $dictionary; |
|
| 220 | } |
|
| 221 | ||
| 222 | /** |
|
| 223 | * Get the results of the relationship. |
|