# fluent-cart/1.6.2/app/Models/WpModels/TermTaxonomy.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.6.2. 74 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.6.2/code/app/Models/WpModels/TermTaxonomy.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.6.2/raw/app/Models/WpModels/TermTaxonomy.php
- Modified: 2025-11-20T13:11:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/1.6.2/code/app/Models/WpModels/TermTaxonomy.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Models\WpModels;

use FluentCart\App\Models\Concerns\CanSearch;
use FluentCart\App\Models\Model;
use FluentCart\App\Models\Product;

class TermTaxonomy extends Model
{
    use CanSearch;
    protected $table = 'term_taxonomy';
    protected $primaryKey = 'term_id';


    public function termRelationships()
    {
        return $this->hasMany(TermRelationship::class, 'term_taxonomy_id', 'term_taxonomy_id');
    }

    /**
     * Get the term that owns the taxonomy
     */
    public function term()
    {
        return $this->belongsTo(Term::class, 'term_id', 'term_id');
    }

    /**
     * Get the parent taxonomy
     */
    public function parent()
    {
        return $this->belongsTo(TermTaxonomy::class, 'parent', 'term_taxonomy_id');
    }

    public function taxonomy()
    {
        return $this->belongsTo(Term::class, 'term_id', 'term_id');
    }


    /**
     * Get child taxonomies
     */
    public function children()
    {
        return $this->hasMany(TermTaxonomy::class, 'parent', 'term_taxonomy_id');
    }

    /**
     * Get all relationships for this taxonomy
     */
    public function relationships()
    {
        return $this->hasMany(TermRelationship::class, 'term_taxonomy_id', 'term_taxonomy_id');
    }

    /**
     * Get all products for this taxonomy
     */
    public function products()
    {
        return $this->hasManyThrough(
            Product::class,
            TermRelationship::class,
            'term_taxonomy_id', // Foreign key on term_relationships
            'ID', // Foreign key on products
            'term_taxonomy_id', // Local key on term_taxonomy
            'object_id' // Local key on term_relationships
        );
    }
}

```
