1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-23 18:01:35 +02:00
invoiceninja/app/models/Invoice.php

28 lines
400 B
PHP
Raw Normal View History

2013-11-26 13:45:07 +01:00
<?php
class Invoice extends Eloquent
{
protected $softDelete = true;
public function client()
{
return $this->belongsTo('Client');
}
public function invoice_items()
{
return $this->hasMany('InvoiceItem');
}
public function getTotal()
{
$total = 0;
foreach ($this->invoice_items as $invoiceItem)
{
$total += $invoiceItem->qty * $invoiceItem->cost;
}
return $total;
}
}