<?php

namespace App\Models;

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

class SupplierTransaction extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'supplier_id',
        'type',
        'trx_no',                 // ✅ added
        'debit',
        'credit',
        'note',
        'memo_no',
        'memo_photo',
        'payment_proof_photo',
        'user_account_id',
        'posted_at',
    ];

    protected $casts = [
        'posted_at' => 'datetime',
        'debit'     => 'decimal:2',
        'credit'    => 'decimal:2',
    ];

    public function user()     { return $this->belongsTo(User::class); }
    public function supplier() { return $this->belongsTo(Supplier::class); }
    public function account()  { return $this->belongsTo(UserAccount::class, 'user_account_id'); }
}