laravel/laravel — pull request #1378 by tgriesser (2012-10-22 13:25:43+00:00)
Title: Eloquent_to_array

Occasionally, I've needed to convert individual model responses `to_array` before json encoding the entire array. I added an `eloquent_to_array` function which is then called `by eloquent_to_json`.

```
public static function bootstrap($id)
{
$model = static::find($id);

// this array will be converted to json
return Response::json(array(
'users' => $model->to_array(),
'messages' => eloquent_to_array($model->messages()->get()),
'accounts' => eloquent_to_array($model->inbox()->get())
));
}
```