<?php

namespace App\Models;

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

class MainSubAccount extends Model
{
    use HasFactory, SoftDeletes;

    protected $table = 'main_sub_accounts';

    protected $fillable = [
        'parent_id',
        'account_code',
        'sub_name',
        'account_type'
    ];

    public function mainAccount()
    {
        return $this->belongsTo(MainAccount::class, 'parent_id');
    }

    public function accountType()
    {
        return $this->belongsTo(AccountType::class, 'account_type', 'id');
    }

    public function subAccounts1()
    {
        return $this->hasMany(SubAccount1::class, 'parent_id');
    }
}
