From ff4b43c72f9ae2a4af72e3fa7b58aecd78e6029c Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 23 Nov 2012 03:23:13 +0100 Subject: [PATCH] Ignore hidden relationships in to_array(). --- laravel/database/eloquent/model.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index d3654a86..b450d21a 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -615,6 +615,9 @@ public function to_array() foreach ($this->relationships as $name => $models) { + // Relationships can be marked as "hidden", too. + if (in_array($name, static::$hidden)) continue; + // If the relationship is not a "to-many" relationship, we can just // to_array the related model and add it as an attribute to the // array of existing regular attributes we gathered.