<?php

namespace App\Models\Customers;

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

class CustomerCreditLedger extends Model
{
    use BelongsToTenant;

    protected $table = 'customer_credit_ledger';

    public $timestamps = false;

    protected $fillable = [
        'customer_id', 'type', 'amount', 'reference_type', 'reference_id',
        'balance_after', 'note', 'created_by', 'created_at',
    ];

    protected function casts(): array
    {
        return [
            'amount' => 'decimal:2',
            'balance_after' => 'decimal:2',
            'created_at' => 'datetime',
        ];
    }

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