<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class AccountGroup extends Model
{
    public $timestamps = false;

    protected $fillable = ['primary_category_id', 'name','company_id'];

    public function primaryCategory(): BelongsTo
    {
        return $this->belongsTo(PrimaryCategory::class);
    }

    public function types(): HasMany
    {
        return $this->hasMany(AccountType::class);
    }
    
    public function category(){
       // The second parameter is the foreign key in your account_groups table
       return $this->belongsTo(PrimaryCategory::class, 'primary_category_id'); 
    }
}