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

33 lines
479 B
PHP
Executable File

<?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;
}
}
Invoice::created(function($invoice)
{
Activity::createInvoice($invoice);
});