From f6388e26be99bdb7ff76645caa066f4ef0ad4a2e Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 16 Apr 2012 20:38:31 -0500 Subject: [PATCH 1/2] added dd helper. --- laravel/helpers.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/laravel/helpers.php b/laravel/helpers.php index 87c3394f..5c4a6945 100644 --- a/laravel/helpers.php +++ b/laravel/helpers.php @@ -26,6 +26,17 @@ function __($key, $replacements = array(), $language = null) return Laravel\Lang::line($key, $replacements, $language); } +/** + * Dump the given value and kill the script. + * + * @param mixed $value + * @return void + */ +function dd($value) +{ + die(var_dump($value)); +} + /** * Get an item from an array using "dot" notation. * From b7ac667405de382b504346ff30a42fb9acb82550 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 17 Apr 2012 14:33:17 -0500 Subject: [PATCH 2/2] tweak belongs to eager constraining. --- laravel/database/eloquent/relationships/belongs_to.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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));