<?php

namespace App\Models;

use App\Traits\GlobalStatus;
use Illuminate\Database\Eloquent\Model;

class KnowledgeCategory extends Model
{
    use GlobalStatus;

    public function scopeParent($query)
    {
        return $query->where('knowledge_category_id', 0);
    }

    public function knowledge()
    {
        return $this->hasMany(Knowledge::class);
    }

    public function subcategoriesKnowledge()
    {
        return $this->hasMany(Knowledge::class, 'knowledge_subcategory_id');
    }

    public function subcategories()
    {
        return $this->hasMany(KnowledgeCategory::class, 'knowledge_category_id');
    }

    public function admin()
    {
        return $this->belongsTo(Admin::class);
    }

}
