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

66 lines
1.3 KiB
PHP
Raw Normal View History

2015-03-18 00:39:03 +01:00
<?php namespace App\Models;
2015-03-16 22:45:25 +01:00
2015-03-31 11:38:24 +02:00
use Illuminate\Database\Eloquent\SoftDeletes;
2015-03-16 22:45:25 +01:00
class Payment extends EntityModel
{
2015-03-31 11:38:24 +02:00
use SoftDeletes;
protected $dates = ['deleted_at'];
2015-03-16 22:45:25 +01:00
public function invoice()
{
2015-03-31 11:38:24 +02:00
return $this->belongsTo('App\Models\Invoice')->withTrashed();
2015-03-16 22:45:25 +01:00
}
public function invitation()
{
2015-03-31 11:38:24 +02:00
return $this->belongsTo('App\Models\Invitation');
2015-03-16 22:45:25 +01:00
}
public function client()
{
2015-03-31 11:38:24 +02:00
return $this->belongsTo('App\Models\Client')->withTrashed();
2015-03-16 22:45:25 +01:00
}
public function account()
{
2015-03-31 11:38:24 +02:00
return $this->belongsTo('App\Models\Account');
2015-03-16 22:45:25 +01:00
}
public function contact()
{
2015-03-31 11:38:24 +02:00
return $this->belongsTo('App\Models\Contact');
2015-03-16 22:45:25 +01:00
}
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);
});