|
|
@@ -24,6 +24,15 @@ class ItemCategory extends ModelCore
|
|
|
*/
|
|
|
protected $table = 'item_categories';
|
|
|
|
|
|
+ protected $titleColumn = 'name';
|
|
|
+
|
|
|
+ protected $orderColumn = 'sort';
|
|
|
+
|
|
|
+ protected $parentColumn = 'parent_id';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 可批量赋值的属性
|
|
|
*
|
|
|
@@ -37,18 +46,8 @@ class ItemCategory extends ModelCore
|
|
|
'parent_id',
|
|
|
];
|
|
|
|
|
|
- /**
|
|
|
- * 树形结构字段设置
|
|
|
- */
|
|
|
- public function __construct(array $attributes = [])
|
|
|
- {
|
|
|
- parent::__construct($attributes);
|
|
|
|
|
|
- // 设置树形结构相关字段
|
|
|
- $this->setTitleColumn('name');
|
|
|
- $this->setOrderColumn('sort');
|
|
|
- $this->setParentColumn('parent_id');
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取该分类下的所有物品
|
|
|
@@ -57,7 +56,7 @@ class ItemCategory extends ModelCore
|
|
|
*/
|
|
|
public function items(): HasMany
|
|
|
{
|
|
|
- return $this->hasMany(ItemItem::class, 'category_id', 'id');
|
|
|
+ return $this->hasMany(Item::class, 'category_id', 'id');
|
|
|
}
|
|
|
|
|
|
/**
|