4
0
Fork 0

更新 'src/Models/GoodsSku.php'

master
panliang 2022-11-07 12:51:45 +08:00
parent 8c81f3f2c4
commit ffb5a6056a
1 changed files with 5 additions and 2 deletions

View File

@ -33,8 +33,11 @@ class GoodsSku extends Model
{
foreach ($params as $item) {
foreach ($item as $key => $value) {
$value = is_string($value) ? '"'.$value.'"' : $value;
$q->whereRaw('json_contains(spec->>"$[*].'.$key."\", '".$value."')");
if (in_array($key, ["name", "value"])) {
$key = trim($key);
$value = trim($value);
$q->whereRaw("json_contains(spec, json_object('$key', '$value'))");
}
}
}