小程序首页配置

This commit is contained in:
liu
2026-08-14 12:41:18 +08:00
parent 889f987f17
commit 8b3cef5af0
21 changed files with 1350 additions and 3 deletions
@@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers\Mini;
use App\Models\HomeBannerModel;
use App\Models\HomeNavModel;
use App\Models\HomePromoModel;
use Illuminate\Http\JsonResponse;
use Modules\AnnoRoute\Attribute\GetRoute;
use Modules\AnnoRoute\Attribute\RequestAttribute;
/**
* 小程序首页配置(轮播图 + 宫格导航 + 促销推荐卡片,仅返回启用项)
*/
#[RequestAttribute('/mini', 'mini', authGuard: 'users')]
class HomeController extends BaseMiniController
{
/** 首页配置聚合:banners / navs / promos,按 sort 升序 */
#[GetRoute('/home', authorize: false)]
public function index(): JsonResponse
{
$banners = HomeBannerModel::query()
->where('status', HomeBannerModel::STATUS_NORMAL)
->orderBy('sort')
->orderBy('id')
->get(['id', 'title', 'image_id', 'link', 'sort']);
$navs = HomeNavModel::query()
->where('status', HomeNavModel::STATUS_NORMAL)
->orderBy('sort')
->orderBy('id')
->get(['id', 'name', 'image_id', 'link', 'sort']);
$promos = HomePromoModel::query()
->where('status', HomePromoModel::STATUS_NORMAL)
->orderBy('sort')
->orderBy('id')
->get(['id', 'title', 'sub_title', 'image_id', 'link', 'sort']);
return $this->success([
'banners' => $banners,
'navs' => $navs,
'promos' => $promos,
]);
}
}