Files
orico-official-website/app/admin/model/v1/ProductCompatPartsModel.php
jsasg 3545b82015
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 5s
feat: 新增产品兼容数据、产品兼容数据配件类型相关接口
2026-07-08 16:59:47 +08:00

49 lines
1.2 KiB
PHP

<?php
declare (strict_types = 1);
namespace app\admin\model\v1;
use app\common\model\ProductCompatPartsBaseModel;
use think\model\concern\SoftDelete;
/**
* @mixin \think\Model
*/
class ProductCompatPartsModel extends ProductCompatPartsBaseModel
{
// 启用软件删除
use SoftDelete;
// 软件删除时间字段
protected $deleteTime = 'deleted_at';
// 状态获取器
public function getStatusTextAttr($value, array $data)
{
$status = ['启用', '禁用'];
return $status[$data['status']];
}
// 按所属语言查询
public function scopeLanguage(\think\db\Query $query, int $value)
{
$query->where('language_id', $value);
}
// 按类型名称查询
public function scopePartName(\think\db\Query $query, string|array $value)
{
if (is_array($value)) {
$query->where('name', 'in', $value);
return;
}
$query->where('name', '=', $value);
}
// 查询配件类型名称搜索
public function searchNameAttr(\think\db\Query $query, string|null $value, array $data)
{
if (is_null($value)) return;
$query->where('name', 'like', '%' . $value . '%');
}
}