tweak belongs to eager constraining.
This commit is contained in:
parent
f6388e26be
commit
b7ac667405
|
@ -65,7 +65,10 @@ public function eagerly_constrain($results)
|
|||
// are looking for the parent of a child model in this relationship.
|
||||
foreach ($results as $result)
|
||||
{
|
||||
$keys[] = $result->{$this->foreign_key()};
|
||||
if ( ! is_null($key = $result->{$this->foreign_key()}))
|
||||
{
|
||||
$keys[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
$this->table->where_in($this->model->key(), array_unique($keys));
|
||||
|
|
Loading…
Reference in New Issue