protected function buildDictionary(Collection $results)
{
$dictionary = array();
// First we will create a dictionary of models keyed by the foreign key of the
// relationship as this will allow us to quickly access all of the related
// models without having to do nested looping which will be quite slow.
foreach ($results as $result) {
$dictionary[(string) $result->{$this->foreignKey}][] = $result;
}
return $dictionary;
}