1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00
invoiceninja/app/Models/Payment.php
2015-03-18 09:39:03 +10:00

61 lines
1.2 KiB
PHP

<?php namespace App\Models;
class Payment extends EntityModel
{
public function invoice()
{
return $this->belongsTo('Invoice')->withTrashed();
}
public function invitation()
{
return $this->belongsTo('Invitation');
}
public function client()
{
return $this->belongsTo('Client')->withTrashed();
}
public function account()
{
return $this->belongsTo('Account');
}
public function contact()
{
return $this->belongsTo('Contact');
}
public function getAmount()
{
return Utils::formatMoney($this->amount, $this->client->currency_id);
}
public function getName()
{
return trim("payment {$this->transaction_reference}");
}
public function getEntityType()
{
return ENTITY_PAYMENT;
}
}
Payment::created(function ($payment) {
Activity::createPayment($payment);
});
Payment::updating(function ($payment) {
Activity::updatePayment($payment);
});
Payment::deleting(function ($payment) {
Activity::archivePayment($payment);
});
Payment::restoring(function ($payment) {
Activity::restorePayment($payment);
});