From a8141c3fb321a8dc2e3bb658233997efaed1d2bd Mon Sep 17 00:00:00 2001 From: Matt April Date: Sat, 7 Sep 2019 20:14:27 -0400 Subject: [PATCH] Change 'self' references inside models to 'static'. This fixes issues when models are overriden, but he base class continues to references itself rather than the new model. --- packages/Webkul/Checkout/src/Models/CartItem.php | 2 +- packages/Webkul/Product/src/Models/Product.php | 12 ++++++------ packages/Webkul/Product/src/Models/ProductFlat.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/Webkul/Checkout/src/Models/CartItem.php b/packages/Webkul/Checkout/src/Models/CartItem.php index 3a53425cb..b4c826a07 100755 --- a/packages/Webkul/Checkout/src/Models/CartItem.php +++ b/packages/Webkul/Checkout/src/Models/CartItem.php @@ -53,6 +53,6 @@ class CartItem extends Model implements CartItemContract */ public function child() { - return $this->belongsTo(self::class, 'id', 'parent_id'); + return $this->belongsTo(static::class, 'id', 'parent_id'); } } diff --git a/packages/Webkul/Product/src/Models/Product.php b/packages/Webkul/Product/src/Models/Product.php index 8a5577e23..ef94811a5 100755 --- a/packages/Webkul/Product/src/Models/Product.php +++ b/packages/Webkul/Product/src/Models/Product.php @@ -38,7 +38,7 @@ class Product extends Model implements ProductContract */ public function variants() { - return $this->hasMany(self::class, 'parent_id'); + return $this->hasMany(static::class, 'parent_id'); } /** @@ -54,7 +54,7 @@ class Product extends Model implements ProductContract */ public function parent() { - return $this->belongsTo(self::class, 'parent_id'); + return $this->belongsTo(static::class, 'parent_id'); } /** @@ -120,7 +120,7 @@ class Product extends Model implements ProductContract */ public function related_products() { - return $this->belongsToMany(self::class, 'product_relations', 'parent_id', 'child_id')->limit(4); + return $this->belongsToMany(static::class, 'product_relations', 'parent_id', 'child_id')->limit(4); } /** @@ -128,7 +128,7 @@ class Product extends Model implements ProductContract */ public function up_sells() { - return $this->belongsToMany(self::class, 'product_up_sells', 'parent_id', 'child_id')->limit(4); + return $this->belongsToMany(static::class, 'product_up_sells', 'parent_id', 'child_id')->limit(4); } /** @@ -136,7 +136,7 @@ class Product extends Model implements ProductContract */ public function cross_sells() { - return $this->belongsToMany(self::class, 'product_cross_sells', 'parent_id', 'child_id')->limit(4); + return $this->belongsToMany(static::class, 'product_cross_sells', 'parent_id', 'child_id')->limit(4); } /** @@ -214,7 +214,7 @@ class Product extends Model implements ProductContract */ public function getAttribute($key) { - if (! method_exists(self::class, $key) && ! in_array($key, ['parent_id', 'attribute_family_id']) && ! isset($this->attributes[$key])) { + if (! method_exists(static::class, $key) && ! in_array($key, ['parent_id', 'attribute_family_id']) && ! isset($this->attributes[$key])) { if (isset($this->id)) { $this->attributes[$key] = ''; diff --git a/packages/Webkul/Product/src/Models/ProductFlat.php b/packages/Webkul/Product/src/Models/ProductFlat.php index 90caf6b23..33038be2b 100644 --- a/packages/Webkul/Product/src/Models/ProductFlat.php +++ b/packages/Webkul/Product/src/Models/ProductFlat.php @@ -34,7 +34,7 @@ class ProductFlat extends Model implements ProductFlatContract */ public function variants() { - return $this->hasMany(self::class, 'parent_id'); + return $this->hasMany(static::class, 'parent_id'); } /**