osb/app/Models/PaymentItem.php

38 lines
627 B
PHP
Raw Normal View History

2018-05-20 12:53:14 +00:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
2022-04-22 05:23:08 +00:00
use App\Traits\PushNew;
2020-07-27 04:49:59 +00:00
2018-05-20 12:53:14 +00:00
class PaymentItem extends Model
{
use PushNew;
2020-07-27 04:49:59 +00:00
2022-06-13 05:46:38 +00:00
public $timestamps = FALSE;
/* RELATIONS */
public function invoice()
{
return $this->belongsTo(Invoice::class);
}
2020-07-27 04:49:59 +00:00
public function payment() {
return $this->belongsTo(Payment::class);
}
/* ATTRIBUTES */
/**
* If our amount is negative, and invoice_id is null, then this is a reversal.
*
* @param $value
* @return float
*/
public function getAllocAmtAttribute($value): float
{
return (is_null($this->invoice_id) && $value < 0) ? -$value : $value;
}
2018-05-20 12:53:14 +00:00
}