|
@@ -651,7 +651,10 @@ class ProductService extends Service
|
|
->orderby('id', 'desc');
|
|
->orderby('id', 'desc');
|
|
|
|
|
|
if(! empty($data['title_t'])) {
|
|
if(! empty($data['title_t'])) {
|
|
- $model->where('title', 'LIKE', '%'.$data['title_t'].'%')
|
|
|
|
|
|
+ // 清理用户输入,去除前后空白并替换多个连续空格为单个空格
|
|
|
|
+ $cleanTitle = preg_replace('/\s+/', ' ', trim($data['title_t']));
|
|
|
|
+ // 构建查询时使用 TRIM 和 REPLACE 来清理数据库字段中的空白字符
|
|
|
|
+ $model->whereRaw("TRIM(REPLACE(title, ' ', '')) LIKE ?", ['%' . str_replace(' ', '', $cleanTitle) . '%'])
|
|
->orWhere('code', 'LIKE', '%'.$data['title_t'].'%')
|
|
->orWhere('code', 'LIKE', '%'.$data['title_t'].'%')
|
|
->orWhere('size', 'LIKE', '%'.$data['title_t'].'%');
|
|
->orWhere('size', 'LIKE', '%'.$data['title_t'].'%');
|
|
}
|
|
}
|