# fluent-cart/1.6.4/app/Models/WpModels/Term.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.6.4. 53 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.6.4/code/app/Models/WpModels/Term.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.6.4/raw/app/Models/WpModels/Term.php
- Modified: 2025-10-14T16:36:46+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.4/code/app/Models/WpModels/Term.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Models\WpModels;

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

class Term extends Model
{
    use CanSearch;
    
    protected $table = 'terms';

    /**
     * The primary key for the model.
     *
     * @var string
     */
    protected $primaryKey = 'term_id';

    public function taxonomy(): \FluentCart\Framework\Database\Orm\Relations\HasOne
    {
        return $this->hasOne(TermTaxonomy::class, 'term_id', 'term_id');
    }

    /**
     * Get the taxonomies for the term
     */
    public function taxonomies()
    {
        return $this->hasMany(TermTaxonomy::class, 'term_id', 'term_id');
    }


    /**
     * Get products associated with this term
     */
    public function products()
    {
        return $this->hasManyThrough(
            Product::class,
            TermRelationship::class,
            'term_taxonomy_id', // Foreign key on term_relationships
            'ID', // Foreign key on products
            'term_id', // Local key on terms
            'object_id' // Local key on term_relationships
        )->join('term_taxonomy', 'term_relationships.term_taxonomy_id', '=', 'term_taxonomy.term_taxonomy_id')
            ->where('term_taxonomy.term_id', $this->term_id);
    }

}

```
