38 lines
982 B
PHP
38 lines
982 B
PHP
|
|
<?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();
|
|||
|
|
}
|
|||
|
|
}
|