<?php

namespace App\Models;

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

class JenisDokumen extends Model
{
    use HasFactory;
    protected $table = 'jenis_dokumens_tables';
    protected $fillable = [
        'nama',
        // 'level',
        'parent_id'
    ];


    public function children(){
        return $this->hasMany("App\Models\JenisDokumen", "parent_id", "id")->with('children');
    }
    public function parent(){
        return $this->belongsToOne("App\Models\JenisDokumen", "id", "parent_id");
    }

    public function grandchildren()
    {
        return $this->children()->with('grandchildren');
    }


}
