2022-03-29 19:20:43 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Reliese Model.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class NhInsurancesInvoice extends Model
|
|
|
|
{
|
|
|
|
protected $table = 'nh_insurances_invoices';
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
'insurance_id' => 'int',
|
|
|
|
'subscription_id' => 'int',
|
2022-03-30 10:32:40 +00:00
|
|
|
'deadline_number' => 'int'
|
2022-03-29 19:20:43 +00:00
|
|
|
];
|
|
|
|
|
2022-05-02 07:03:42 +00:00
|
|
|
protected $guarded = ['id'];
|
2022-05-04 10:52:01 +00:00
|
|
|
protected $appends = ['paid_amount_non_formatted'];
|
2022-03-29 19:20:43 +00:00
|
|
|
|
|
|
|
public function insurance()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(NhInsurance::class, 'insurance_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function subscription()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(NhInsurancesSubscription::class, 'subscription_id');
|
|
|
|
}
|
2022-05-04 10:52:01 +00:00
|
|
|
|
|
|
|
public function payments()
|
|
|
|
{
|
|
|
|
return $this->hasMany(NhInsurancesPayment::class, 'invoice_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPaidAmountNonFormattedAttribute()
|
|
|
|
{
|
|
|
|
return $this->payments()->sum('amount');
|
|
|
|
}
|
2022-03-29 19:20:43 +00:00
|
|
|
}
|