Skip to content

Instantly share code, notes, and snippets.

@hodaddy
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hodaddy/8739373 to your computer and use it in GitHub Desktop.
Save hodaddy/8739373 to your computer and use it in GitHub Desktop.
ticketBalance manual join 1
$ticketBalance = DB::table('invoice AS i')
->join('invoice_ticket AS it', 'it.invoice_id', '=', 'i.id')
->join('ticket AS t', 't.id', '=', 'it.ticket_id')
->select(array(DB::raw('SUM(t.cost) as totalTicketsCost')))
->where('i.id', '=', $invoiceId)
->first();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment