<?php

namespace CliqThemes\ORM\Entities;

use CliqThemes\ORM\Model;

/**
 * ORM model representing the wp_term_taxonomy table.
 */
class TermTaxonomy extends Model
{
    protected string $table = 'term_taxonomy';

    protected string $primaryKey = 'term_taxonomy_id';

    protected array $fillable = [
        'term_id',
        'taxonomy',
        'description',
        'parent',
        'count',
    ];

    protected bool $timestamps = false;

    /**
     * Relationship back to the term this taxonomy entry belongs to.
     */
    public function term()
    {
        return $this->belongsTo(Term::class, 'term_id', 'term_id');
    }

    /**
     * Relationship to the objects attached to this taxonomy entry.
     */
    public function relationships()
    {
        return $this->hasMany(TermRelationship::class, 'term_taxonomy_id', 'term_taxonomy_id');
    }
}

