feat: 优化 SystemStoreStorageLists 类中的查询逻辑

This commit is contained in:
mkm 2024-07-22 11:26:31 +08:00
parent c8b5607300
commit 2df0bf5c1f

View File

@ -63,8 +63,14 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
$item['staff_name'] = '无'; $item['staff_name'] = '无';
} }
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,image')->find(); $find = StoreProduct::where('id', $item['product_id'])->field('store_name,image')->find();
if ($find) {
$item['store_name'] = $find['store_name']; $item['store_name'] = $find['store_name'];
$item['image'] = $find['image']; $item['image'] = $find['image'];
} else {
$item['store_name'] = '';
$item['image'] = '';
}
return $item; return $item;
}) })
->toArray(); ->toArray();
@ -81,5 +87,4 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
{ {
return SystemStoreStorage::where($this->searchWhere)->count(); return SystemStoreStorage::where($this->searchWhere)->count();
} }
} }