Skip to content

Instantly share code, notes, and snippets.

@abfan1127
Created January 30, 2014 18:09
Show Gist options
  • Save abfan1127/8714917 to your computer and use it in GitHub Desktop.
Save abfan1127/8714917 to your computer and use it in GitHub Desktop.
Eloquent example
// http://help.laravel.io/057572a2437e89584b95082c178617e8d5fd934b
$ticketResult = $this->getInvoiceTickets()->with( array(
'getTicket' => function ($query) {
$query->sum('costs')->as('costs); // check the sum method in the Eloquent Builder source file
}
))->get()->first();
echo $ticketResult->getTicket; // or whatever the design pattern is
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment