Last active
August 29, 2015 13:55
-
-
Save hodaddy/8738681 to your computer and use it in GitHub Desktop.
Invoice Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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