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 / TermTaxonomy.php

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

74 lines 1.7 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\Concerns\CanSearch;
6 use FluentCart\App\Models\Model;
7 use FluentCart\App\Models\Product;
8
9 class TermTaxonomy extends Model
10 {
11 use CanSearch;
12 protected $table = 'term_taxonomy';
13 protected $primaryKey = 'term_id';
14
15
16 public function termRelationships()
17 {
18 return $this->hasMany(TermRelationship::class, 'term_taxonomy_id', 'term_taxonomy_id');
19 }
20
21 /**
22 * Get the term that owns the taxonomy
23 */
24 public function term()
25 {
26 return $this->belongsTo(Term::class, 'term_id', 'term_id');
27 }
28
29 /**
30 * Get the parent taxonomy
31 */
32 public function parent()
33 {
34 return $this->belongsTo(TermTaxonomy::class, 'parent', 'term_taxonomy_id');
35 }
36
37 public function taxonomy()
38 {
39 return $this->belongsTo(Term::class, 'term_id', 'term_id');
40 }
41
42
43 /**
44 * Get child taxonomies
45 */
46 public function children()
47 {
48 return $this->hasMany(TermTaxonomy::class, 'parent', 'term_taxonomy_id');
49 }
50
51 /**
52 * Get all relationships for this taxonomy
53 */
54 public function relationships()
55 {
56 return $this->hasMany(TermRelationship::class, 'term_taxonomy_id', 'term_taxonomy_id');
57 }
58
59 /**
60 * Get all products for this taxonomy
61 */
62 public function products()
63 {
64 return $this->hasManyThrough(
65 Product::class,
66 TermRelationship::class,
67 'term_taxonomy_id', // Foreign key on term_relationships
68 'ID', // Foreign key on products
69 'term_taxonomy_id', // Local key on term_taxonomy
70 'object_id' // Local key on term_relationships
71 );
72 }
73 }
74