Files
lgp-admin-plus-api/app/Service/wx/WxHomeService.php
LQ bcf54c2727 初始化
缺陷:主题配色需要优化整体的同风格
2026-08-14 23:21:21 +08:00

38 lines
982 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Service\wx;
use App\BaseApp\BaseWxService;
use App\Models\business\CarouselModel;
use App\Models\business\CategoryModel;
/**
* 小程序首页:轮播与一级分类,都不要求登录
*/
class WxHomeService extends BaseWxService
{
protected bool $needLogin = false;
public function carousel(): mixed
{
// 只返回启用中的轮播;后台 status=1 表示隐藏
return CarouselModel::where('deleted_at', 0)
->where('status', 0)
->orderBy('sort', 'asc')
->get(['id', 'url', 'to_path', 'sort']);
}
/**
* 分类列表pid=0 为一级
* 按 sort 升序,同值按 id需已执行 05_cc_category_add_sort.sql
*/
public function categoryList(int $pid = 0): mixed
{
return CategoryModel::where('pid', $pid)
->where('deleted_at', 0)
->orderBy('sort', 'asc')
->orderBy('id', 'asc')
->get();
}
}