如何通过在pivot中提供where子句来选择项目

时间:2014-01-28 14:04:41

标签: sql laravel pivot pivot-table eloquent

这是我现在的代码:

$result = Category::with(array(
            "getProducts",
            "getProducts.getBrand",
            "getProducts.getImages",
            "getProducts.getDetail",
            "getProducts.getTax",
            "getProducts.getDiscount",
            "getProducts.getAttributes" => function($query) use($_temp){
                if($_temp != null){
                    $query->where_in('attributes.id',$_temp);
                }
            },
            "getSlideshow",
            "getSlideshow.getItems",
            "getAttributeListing",
            "getAttributeListing.getAttributes",
            "getAttributeListing.getAttributes.productSpecific"
        ))
        ->where('id','=', $category_id)
        ->first();

然而,它只过滤getProducts.getAttributes项而不是'getProducts'本身。有没有办法可以按属性获取产品?

注意:我使用的是Laravel 3

0 个答案:

没有答案