<?php

declare(strict_types=1);

namespace App\Models\Accounting;

use App\Models\Model;
use App\Models\User;
use App\Models\Market\Organization;

class MemberLedger extends Model
{
    protected ?string $table = 'member_ledgers';

    protected array $fillable = [
        'hashkey',
        'user_id',
        'organization_id',
        'amount',
        'transaction_type',
        'flow',
        'balance_after',
        'description',
        'reference_id',
        'created_by',
        'updated_by',
        'is_active',
    ];

    protected array $casts = [
        'amount' => 'decimal:2',
        'balance_after' => 'decimal:2',
        'is_active' => 'boolean',
    ];

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

    public function organization()
    {
        return $this->belongsTo(Organization::class, 'organization_id');
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function updater()
    {
        return $this->belongsTo(User::class, 'updated_by');
    }
}
