新增搜索商品库存字段返回

This commit is contained in:
2023-03-23 17:20:03 +08:00
parent 9dd6116f44
commit 983f4d8909
8 changed files with 106 additions and 10 deletions
+4 -1
View File
@@ -103,7 +103,10 @@ class Product extends Model
*/
public static function getSearchKeywordList(array $params = [],string $keyword = '',array $fields = ['*']): Collection|array
{
return self::when($keyword, function ($query, $keyword) {
return self::with([
'ProductPlatformAmount:amount_id,product_platform_id,stock'
])
->when($keyword, function ($query, $keyword) {
$query->where(function ($query) use ($keyword) {
$query->orwhere("product_name", 'like', '%' . $keyword . '%');
$query->orwhere("common_name", 'like', '%' . $keyword . '%');