<?php

namespace App\Models;

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

class Cashbook extends Model
{
    use HasFactory;

    protected $table = "cashbooks";
    protected $fillable = ['code', 'gl_account_id', 'description', 'account_type'];
    
    // Set default value for account_type
    protected $attributes = [
        'account_type' => 'cash', // or whatever default value makes sense
    ];

    // Relationship to GeneralLedger
    public function generalLedger()
    {
        return $this->belongsTo(MainAccount::class, 'gl_account_id');
    }
}
