30 lines
634 B
PHP
30 lines
634 B
PHP
<?php
|
|
declare (strict_types = 1);
|
|
|
|
namespace app\admin\model\v1;
|
|
|
|
use app\common\model\ProductRelatedBaseModel;
|
|
|
|
/**
|
|
* 产品 - 关联产品模型
|
|
* @mixin \think\Model
|
|
*/
|
|
class ProductRelatedModel extends ProductRelatedBaseModel
|
|
{
|
|
// 关联产品模型
|
|
public function product()
|
|
{
|
|
return $this->belongsTo(ProductModel::class, 'related_product_id', 'id');
|
|
}
|
|
|
|
// 根据产品ID查询
|
|
public function scopeProductId($query, $id)
|
|
{
|
|
if (is_array($id)) {
|
|
$query->where('product_id', 'in', $id);
|
|
return;
|
|
}
|
|
$query->where('product_id', '=', $id);
|
|
}
|
|
}
|