BF self to static, which allows extendable models
This commit is contained in:
parent
5003f31d7c
commit
beebee6b82
|
|
@ -134,12 +134,12 @@ class Product extends Model implements Purchasable, Cartable
|
|||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
return $this->belongsTo(static::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
return $this->hasMany(static::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function attributes(): HasMany
|
||||
|
|
|
|||
|
|
@ -76,19 +76,19 @@ class ProductCategory extends Model
|
|||
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
return $this->belongsTo(static::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id')
|
||||
return $this->hasMany(static::class, 'parent_id')
|
||||
->where('is_visible', true)
|
||||
->orderBy('sort_order');
|
||||
}
|
||||
|
||||
public function allChildren(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id')
|
||||
return $this->hasMany(static::class, 'parent_id')
|
||||
->orderBy('sort_order');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ trait HasProductRelations
|
|||
public function productRelations(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
self::class,
|
||||
static::class,
|
||||
config('shop.tables.product_relations', 'product_relations'),
|
||||
'product_id',
|
||||
'related_product_id'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class Product extends \Blax\Shop\Models\Product {}
|
||||
Loading…
Reference in New Issue