<?php

namespace App\Models;

use App\Models\Concerns\HasOwnerScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Debt extends Model
{
    use HasOwnerScope;

    protected $fillable = [
        'user_id',
        'external_id',
        'name',
        'balance',
        'original_balance',
        'interest_rate',
        'minimum_payment',
        'due_day',
        'icon',
        'type',
    ];

    protected function casts(): array
    {
        return [
            'balance' => 'float',
            'original_balance' => 'float',
            'interest_rate' => 'float',
            'minimum_payment' => 'float',
            'due_day' => 'integer',
        ];
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
