2025-12-23 23:42:02 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Tenants;
|
|
|
|
|
|
2026-01-29 15:33:54 +09:00
|
|
|
use App\Traits\Auditable;
|
2025-12-23 23:42:02 +09:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
|
|
|
|
class BillInstallment extends Model
|
|
|
|
|
{
|
2026-01-29 15:33:54 +09:00
|
|
|
use Auditable;
|
|
|
|
|
|
2025-12-23 23:42:02 +09:00
|
|
|
protected $fillable = [
|
|
|
|
|
'bill_id',
|
2026-03-07 02:58:55 +09:00
|
|
|
'type',
|
2025-12-23 23:42:02 +09:00
|
|
|
'installment_date',
|
|
|
|
|
'amount',
|
2026-03-07 02:58:55 +09:00
|
|
|
'counterparty',
|
2025-12-23 23:42:02 +09:00
|
|
|
'note',
|
|
|
|
|
'created_by',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'installment_date' => 'date',
|
|
|
|
|
'amount' => 'decimal:2',
|
|
|
|
|
'bill_id' => 'integer',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 배열/JSON 변환 시 날짜 형식 지정
|
|
|
|
|
*/
|
|
|
|
|
public function toArray(): array
|
|
|
|
|
{
|
|
|
|
|
$array = parent::toArray();
|
|
|
|
|
|
|
|
|
|
if (isset($array['installment_date']) && $this->installment_date) {
|
|
|
|
|
$array['installment_date'] = $this->installment_date->format('Y-m-d');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $array;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 어음 관계
|
|
|
|
|
*/
|
|
|
|
|
public function bill(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Bill::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 생성자 관계
|
|
|
|
|
*/
|
|
|
|
|
public function creator(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(\App\Models\Members\User::class, 'created_by');
|
|
|
|
|
}
|
|
|
|
|
}
|