laravel/laravel — pull request #1023 by douglinsmeyer (2012-07-28 19:54:47+00:00)
Title: Improvement to fluent select

Modified fluent query select method to allow multiple ->select() calls in a chain to augment the result set instead of replace
The primary benefit of this modification is to allow calculated fields to be added to Eloquent relationships.

Ex:
public function widgets()
{
// This relationship will fetch transactions (widget flows) where the total of those flows results in > 0 widgets
// From the result set of this query you can load all Widgets (Widget::find($widget_id)) that have quantity > 0 calculated dynamically
return $this->transactions()->group_by('widget_id')->having('total', '>', '0')->get(array('*', DB::raw('SUM(quantity) as total')));
}