<?php
declare (strict_types = 1);

namespace app\index\model;

use app\common\model\ProductRelatedBaseModel;

/**
 * 相关产品表模型
 * @mixin \think\Model
 */
class ProductRelatedModel extends ProductRelatedBaseModel
{
    // 关联产品
    public function product()
    {
        return $this->hasOne(ProductModel::class, 'id', 'related_product_id');
    }

    // 所属产品范围查询
    public function scopeByProductId($builder, $product_id)
    {
        return $builder->where('product_id', '=', $product_id);
    }
}
