feat: 产品分类推荐数据管理
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 3s

This commit is contained in:
2026-03-27 14:03:14 +08:00
parent 61728434d3
commit a1c7ae62ba
8 changed files with 416 additions and 4 deletions

View File

@@ -0,0 +1,47 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\v1;
use app\common\model\ProductCategoryRecommendBaseModel;
use think\model\concern\SoftDelete;
/**
* 产品分类推荐模型
* @mixin \think\Model
*/
class ProductCategoryRecommendModel extends ProductCategoryRecommendBaseModel
{
// 启用软件删除
use SoftDelete;
// 软件删除时间字段
protected $deleteTime = 'deleted_at';
// 关联语言
public function language()
{
return $this->belongsTo(\app\index\model\LanguageModel::class, 'language_id', 'id');
}
// 关联产品分类
public function category()
{
return $this->belongsTo(\app\index\model\ProductCategoryModel::class, 'category_id', 'id');
}
// 所属语言范围查询
public function scopeLanguage($query, $language)
{
$query->where('language_id', '=', $language);
}
// 关键词搜索
public function searchKeywordsAttr($query, string|null $keywords)
{
if (is_null($keywords)) {
return;
}
$query->where('title', 'like', "%{$keywords}%")
->whereOr('desc', 'like', "%{$keywords}%");
}
}