All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 5s
56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
declare (strict_types = 1);
|
|
|
|
namespace app\admin\model\v1;
|
|
|
|
use app\common\model\ProductCompatBaseModel;
|
|
use think\model\concern\SoftDelete;
|
|
|
|
/**
|
|
* @mixin \think\Model
|
|
*/
|
|
class ProductCompatModel extends ProductCompatBaseModel
|
|
{
|
|
// 启用软件删除
|
|
use SoftDelete;
|
|
// 软件删除时间字段
|
|
protected $deleteTime = 'deleted_at';
|
|
|
|
// 关联配件类型
|
|
public function parts()
|
|
{
|
|
return $this->hasOne(ProductCompatPartsModel::class, 'id', 'part_id');
|
|
}
|
|
|
|
// 按所属语言查询
|
|
public function scopeLanguage(\think\db\Query $query, int $value)
|
|
{
|
|
$query->where('language_id', $value);
|
|
}
|
|
|
|
// 按型号查询
|
|
public function scopeModelName(\think\db\Query $query, string|array $value)
|
|
{
|
|
if (is_array($value)) {
|
|
$query->where('model', 'in', $value);
|
|
return;
|
|
}
|
|
|
|
$query->where('model', '=', $value);
|
|
}
|
|
|
|
// 按标签名称搜索
|
|
public function searchLabelNameAttr(\think\db\Query $query, string|null $value, array $data)
|
|
{
|
|
if (is_null($value)) return;
|
|
$query->where('label_name', 'like', '%' . $value . '%');
|
|
}
|
|
|
|
// 按型号搜索
|
|
public function searchModelAttr(\think\db\Query $query, string|null $value, array $data)
|
|
{
|
|
if (is_null($value)) return;
|
|
$query->where('model', 'like', '%' . $value . '%');
|
|
}
|
|
}
|