feat: index - 首页及顶部导航处理

This commit is contained in:
2025-04-07 18:10:50 +08:00
parent d75563f487
commit e8e77b6d48
101 changed files with 5823 additions and 5 deletions

View File

@@ -0,0 +1,53 @@
<?php
declare (strict_types = 1);
namespace app\index\model;
use app\common\model\SysBannerBaseModel;
use think\model\concern\SoftDelete;
/**
* 横幅(分类)模型
* @mixin \think\Model
*/
class SysBannerModel extends SysBannerBaseModel
{
// 启用软删除
use SoftDelete;
// 软删除字段
protected $deleteTime = 'deleted_at';
// 关联横幅数据项
public function items()
{
return $this->hasMany(SysBannerItemModel::class, 'banner_id', 'id');
}
// 唯一标识范围查询
public function scopeUniqueLabel($query, string|array $unique_label)
{
if (is_array($unique_label)) {
$query->whereIn('unique_label', $unique_label);
return;
}
$query->where('unique_label', '=', $unique_label);
}
// 所属语言范围查询
public function scopeLanguage($query, $language)
{
$query->where('language_id', '=', $language);
}
// 首页推荐状态范围查询
public function scopeRecommend($query, bool $recommend = true)
{
$query->where('recommend', '=', (int)$recommend);
}
// 启用状态范围查询
public function scopeEnabled($query, bool $enabled = true)
{
$query->where('status', '=', (int)$enabled);
}
}