Skip to content

Instantly share code, notes, and snippets.

@hodaddy
Last active August 29, 2015 13:55
Show Gist options
  • Save hodaddy/8738681 to your computer and use it in GitHub Desktop.
Save hodaddy/8738681 to your computer and use it in GitHub Desktop.
Invoice Model
<?php
class Invoice extends Eloquent {
protected $table = 'invoice';
public function getInvoiceTickets()
{
return $this->hasMany('InvoiceTicket', 'invoice_id');
}
public function getInvoiceBalance() {
$ticketResult = $this->getInvoiceTickets()->with('getTicket')
->get( array(
DB::raw( 'SUM(cost) AS costs')
));
return $ticketResult[0]->costs;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment