function match(Model $parent) { foreach ($this->eagerResults as $row) { if ($row->{$this->foreign_key} == $parent->getData($parent->getPrimaryKey())) { return $row; } } }
function match(Model $parent) { $return = array(); foreach ($this->eagerResults as $row) { foreach ($this->pivot_result as $pivot_row) { if ($parent->getData($parent->getPrimaryKey()) == $pivot_row[$this->foreign_key] and $row->getData($row->getPrimaryKey()) == $pivot_row[$this->other_key]) { $return[] = $row; break; } } } return $return; }