<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class BalanceAdjustment extends Model
{
    use HasFactory;

    protected $table = 'balance_adjustments';

    protected $fillable = [
        'user_id',
        'admin_id',
        'type',
        'amount',
        'before_balance',
        'after_balance',
        'reason',
    ];

    protected $casts = [
        'amount' => 'integer',
        'before_balance' => 'integer',
        'after_balance' => 'integer',
    ];

    /**
     * User whose balance was adjusted
     */
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    /**
     * Admin who made the adjustment
     */
    public function admin()
    {
        return $this->belongsTo(User::class, 'admin_id');
    }
}
