|
@@ -42,9 +42,12 @@ class DistProduct extends Model
|
|
|
// 静态方法用于查询多个产品
|
|
|
public static function getProducts($categoryId = null, $limit = null)
|
|
|
{
|
|
|
+ $dist=app('dist');
|
|
|
+
|
|
|
$query = self::query();
|
|
|
|
|
|
$query->where('enabled', 1);
|
|
|
+ $query->where('dist_id', $dist->id);
|
|
|
|
|
|
// 如果提供了分类 ID,添加过滤条件
|
|
|
if ($categoryId) {
|
|
@@ -54,6 +57,7 @@ class DistProduct extends Model
|
|
|
// 包括关联数据(图片和分类)
|
|
|
$query->with(['images', 'distProductCategory']);
|
|
|
|
|
|
+ $query->orderBy('is_pinned', 'desc');
|
|
|
// 如果提供了限制数量,限制查询结果
|
|
|
if ($limit) {
|
|
|
return $query->limit($limit)->get();
|