feat: 产品搜索页
This commit is contained in:
@@ -4,6 +4,7 @@ declare (strict_types = 1);
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\ProductBaseModel;
|
||||
use think\facade\Db;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
@@ -74,4 +75,10 @@ class ProductModel extends ProductBaseModel
|
||||
{
|
||||
$query->where('is_new', '=', (int)$stat);
|
||||
}
|
||||
|
||||
// 关键词搜索
|
||||
public function searchKeywordsAttr($query, string $keywords)
|
||||
{
|
||||
$query->whereRaw('BINARY spu LIKE "%' . $keywords . '%" OR BINARY name LIKE "%' . $keywords . '%" OR BINARY short_name LIKE "%' . $keywords . '%"');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user