1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<?php
use Illuminate\Database\Capsule\Manager as DB; use Carbon\Carbon as Carbon;
class ProProductSku extends BaseModel{ protected $table = "pro_product_sku";
public function proProduct(){ return $this->belongsTo('ProProduct', 'product_id'); }
public function proImages(){ return $this->hasMany('ProImage', 'sku_id'); }
public function supplier(){ return $this->belongsTo('Supplier', 'supplier_id'); }
public function warehouseProductskus(){ return $this->hasMany('WarehouseProductsku', 'sku_id'); }
public function getProductName($wlangcode = null){ $wlangcode = $wlangcode ?: $_SESSION["wlangcode"]; return $this->proProduct->{"name_{$wlangcode}"}; }
public function getColorName($wlangcode = null){ $wlangcode = $wlangcode ?: $_SESSION["wlangcode"]; switch($this->color_code){ case "": case "N/A": return ""; default: return $this->{"color_name_{$wlangcode}"}; } } public function getSizeName($wlangcode = null){ $wlangcode = $wlangcode ?: $_SESSION["wlangcode"]; switch($this->size_code){ case "": case "N/A": return ""; default: return $this->{"size_detail_{$wlangcode}"}; } } public function getConfigName($wlangcode = null){ $wlangcode = $wlangcode ?: $_SESSION["wlangcode"]; switch($this->config_code){ case "": case "N/A": return ""; default: return $this->{"config_name_{$wlangcode}"}; } }
public function getProductSkuName($wlangcode = null){ $wlangcode = $wlangcode ?: $_SESSION["wlangcode"]; return $this->getProductName($wlangcode) . " ( " . ($this->getColorName($wlangcode) ? $this->getColorName($wlangcode) . " " : "") . ($this->getSizeName($wlangcode) ? $this->getSizeName($wlangcode) . " " : "") . ($this->getConfigName($wlangcode) ? $this->getConfigName($wlangcode) . " " : "") . ")"; }
}
|