<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

#[Fillable([
    'reference_month',
    'applied_percent',
    'investments_credited',
    'processed_by',
    'processed_at',
])]
class PlatformMonthAccrual extends Model
{
    protected function casts(): array
    {
        return [
            'applied_percent' => 'decimal:4',
            'processed_at' => 'datetime',
        ];
    }

    /**
     * @return BelongsTo<User, PlatformMonthAccrual>
     */
    public function processor(): BelongsTo
    {
        return $this->belongsTo(User::class, 'processed_by');
    }
}
