BF self to static, which allows extendable models

This commit is contained in:
Fabian @ Blax Software 2025-12-09 09:09:23 +01:00
parent 5003f31d7c
commit beebee6b82
4 changed files with 11 additions and 6 deletions

View File

@ -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

View File

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

View File

@ -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'

View File

@ -0,0 +1,5 @@
<?php
namespace App\Models;
class Product extends \Blax\Shop\Models\Product {}