PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.1
1.7.1 1.7.0 1.6.6 1.6.5 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 All 51 releases
fluent-cart / app / Models / AttributeRelation.php

AttributeRelation.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.7.1, at app/Models/AttributeRelation.php

57 lines 1.1 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;
4
5 /**
6 * Attributes Relations Model - DB Model for Attributes Terms to Specific Variations
7 * Maybe we don't need this model. For now, it's here
8 *
9 * Database Model
10 *
11 * @package FluentCart\App\Models
12 *
13 * @version 1.0.0
14 */
15 class AttributeRelation extends Model
16 {
17 protected $table = 'fct_atts_relations';
18
19 protected $fillable = [
20 'group_id',
21 'term_id',
22 'object_id',
23 ];
24
25 public function group()
26 {
27 return $this->belongsTo(AttributeGroup::class, 'group_id', 'id');
28 }
29
30 public function term()
31 {
32 return $this->belongsTo(AttributeTerm::class, 'term_id', 'id');
33 }
34
35 public function variation()
36 {
37 return $this->belongsTo(ProductVariation::class, 'object_id', 'id');
38 }
39
40 /**
41 * The ProductDetail of the product this link's variation belongs to.
42 * object_id holds a ProductVariation id, never a ProductDetail id, so the
43 * detail is resolved through the variation's post_id.
44 */
45 public function productDetails()
46 {
47 return $this->hasOneThrough(
48 ProductDetail::class,
49 ProductVariation::class,
50 'id',
51 'post_id',
52 'object_id',
53 'post_id'
54 );
55 }
56 }
57