diff --git a/laravel/database/eloquent/relationships/belongs_to.php b/laravel/database/eloquent/relationships/belongs_to.php index b73c57bf..ff0d29d5 100644 --- a/laravel/database/eloquent/relationships/belongs_to.php +++ b/laravel/database/eloquent/relationships/belongs_to.php @@ -65,7 +65,10 @@ class Belongs_To extends Relationship { // 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));