feat: 产品分类推荐数据管理
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 3s
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 3s
This commit is contained in:
47
app/admin/model/v1/ProductCategoryRecommendModel.php
Normal file
47
app/admin/model/v1/ProductCategoryRecommendModel.php
Normal 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}%");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user