<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class AccountMapping extends Model
{
    protected $fillable = ['company_id', 'mapping_key', 'account_id'];

    public function account()
    {
        return $this->belongsTo(Account::class);
    }

    /**
     * Helper to get the Account ID for a specific operation
     */
    public static function getAccountId($key)
    {
        return self::where('company_id', auth()->user()->current_company_id)
            ->where('mapping_key', $key)
            ->value('account_id');
    }
}