PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Models / WpModels / Term.php

Term.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Models/WpModels/Term.php

53 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Models\WpModels;
4
5 use FluentCart\App\Models\Model;
6 use FluentCart\App\Models\Concerns\CanSearch;
7 use FluentCart\App\Models\Product;
8
9 class Term extends Model
10 {
11 use CanSearch;
12
13 protected $table = 'terms';
14
15 /**
16 * The primary key for the model.
17 *
18 * @var string
19 */
20 protected $primaryKey = 'term_id';
21
22 public function taxonomy(): \FluentCart\Framework\Database\Orm\Relations\HasOne
23 {
24 return $this->hasOne(TermTaxonomy::class, 'term_id', 'term_id');
25 }
26
27 /**
28 * Get the taxonomies for the term
29 */
30 public function taxonomies()
31 {
32 return $this->hasMany(TermTaxonomy::class, 'term_id', 'term_id');
33 }
34
35
36 /**
37 * Get products associated with this term
38 */
39 public function products()
40 {
41 return $this->hasManyThrough(
42 Product::class,
43 TermRelationship::class,
44 'term_taxonomy_id', // Foreign key on term_relationships
45 'ID', // Foreign key on products
46 'term_id', // Local key on terms
47 'object_id' // Local key on term_relationships
48 )->join('term_taxonomy', 'term_relationships.term_taxonomy_id', '=', 'term_taxonomy.term_taxonomy_id')
49 ->where('term_taxonomy.term_id', $this->term_id);
50 }
51
52 }
53