mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-23 18:01:35 +02:00
28 lines
400 B
PHP
28 lines
400 B
PHP
|
<?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;
|
||
|
}
|
||
|
}
|