Merge pull request #1422 from MattApril/master

Change 'self' references inside models to 'static'. This fixes issues…
This commit is contained in:
Jitendra Singh 2019-09-10 12:45:51 +05:30 committed by GitHub
commit 843fbb1922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -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');
}
}

View File

@ -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] = '';

View File

@ -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');
}
/**