refactor: 修改几在模块支持多分类筛选
This commit is contained in:
@@ -85,6 +85,10 @@ class ArticleModel extends ArticleBaseModel
|
||||
// 分类查询
|
||||
public function scopeCategory($query, $value)
|
||||
{
|
||||
if (is_array($value) || str_contains($value, ',')) {
|
||||
$query->whereIn('category_id', $value);
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $value);
|
||||
}
|
||||
public function scopeCategoryNullable($query, $value)
|
||||
@@ -92,6 +96,10 @@ class ArticleModel extends ArticleBaseModel
|
||||
if (is_null($value)) {
|
||||
return;
|
||||
}
|
||||
if (is_array($value) || str_contains($value, ',')) {
|
||||
$query->whereIn('category_id', $value);
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,10 @@ class AttachmentModel extends AttachmentBaseModel
|
||||
public function scopeCategoryId($query, $value)
|
||||
{
|
||||
if (empty($value)) return;
|
||||
if (is_array($value) || str_contains($value, ',')) {
|
||||
$query->whereIn('category_id', $value);
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,10 +65,18 @@ class ProductModel extends ProductBaseModel
|
||||
if (is_null($value)) {
|
||||
return;
|
||||
}
|
||||
if (is_array($value) || str_contains($value, ',')) {
|
||||
$query->whereIn('category_id', $value);
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $value);
|
||||
}
|
||||
public function scopeCategory($query, $value)
|
||||
{
|
||||
if (is_array($value) || str_contains($value, ',')) {
|
||||
$query->whereIn('category_id', $value);
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $value);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,10 @@ class SysBannerItemModel extends SysBannerItemBaseModel
|
||||
public function scopeBannerId($query, $value)
|
||||
{
|
||||
if (is_null($value)) return;
|
||||
if (is_array($value) || str_contains($value, ',')) {
|
||||
$query->whereIn('banner_id', $value);
|
||||
return;
|
||||
}
|
||||
$query->where('banner_id', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,10 @@ class VideoModel extends VideoBaseModel
|
||||
if (empty($value)) {
|
||||
return;
|
||||
}
|
||||
if (is_array($value) || str_contains($value, ',')) {
|
||||
$query->whereIn('category_id', $value);
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user