本文整理汇总了PHP中AttributeGroup::with方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeGroup::with方法的具体用法?PHP AttributeGroup::with怎么用?PHP AttributeGroup::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeGroup
的用法示例。
在下文中一共展示了AttributeGroup::with方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_index
public function get_index($cat = '', $alias = '')
{
//Filtering the Attribute groups for product specific
if (empty($alias)) {
}
$prod = Product::with(array('getCategory', 'getCategory.getDescriptions'))->where('alias', '=', $cat)->first();
$cat = $prod->getCategory[0]->getDescriptions->alias;
$alias = $prod->alias;
$category_id = CategoryDescription::with('getCategory')->where('alias', '=', $cat)->only('id');
$result = Category::with(array("getDescriptions", "getTopCat", "getTopCat.getDescriptions", "getProducts" => function ($query) use($alias) {
$query->where('alias', '=', $alias);
}, "getProducts.getBrand", "getProducts.getImages", "getProducts.getDetail", "getProducts.getTax", "getProducts.getDiscount", "getProducts.getAttributes", "getProducts.getShipment", "getAttributeListing", "getAttributeListing.getTopGroup"))->where('id', '=', $category_id)->first();
Title::put($result->getProducts[0]->getDetail->name);
/*Get attributes*/
$topGroups = array();
foreach ($result->getAttributeListing as $item) {
array_push($topGroups, $item->getTopGroup->id);
}
$topGroups = array_unique($topGroups);
$groups = array();
foreach ($result->getAttributeListing as $item) {
array_push($groups, $item->id);
}
$groups = array_unique($groups);
$belongedGroups = array();
foreach ($result->getProducts[0]->getAttributes as $item) {
array_push($belongedGroups, $item->id);
}
$attrs = AttributeGroup::with(array('getParentGroup' => function ($query) use($groups) {
$query->order_by('sort_order', 'desc');
$query->where_in('id', $groups);
}, 'getParentGroup.getAttributes' => function ($query) use($belongedGroups) {
$query->where_in('id', $belongedGroups);
}))->where_in('id', $topGroups)->get();
return View::make('products.index')->with('product', $result)->with('attrs', $attrs);
}
示例2: post_productAttribute
public function post_productAttribute()
{
$data = Input::all();
// $attrsTop = AttributeGroup::with(array('getTopGroup','getAttributes'))->where('id','=',$data['id'])->first();
$result = Category::with(array("getAttributeListing", "getAttributeListing.getTopGroup"))->where('id', '=', $data['id'])->first();
$topGroups = array();
foreach ($result->getAttributeListing as $item) {
array_push($topGroups, $item->getTopGroup->id);
}
$topGroups = array_unique($topGroups);
$belongedGroups = array();
foreach ($result->getAttributeListing as $item) {
array_push($belongedGroups, $item->id);
}
$belongedGroups = array_unique($belongedGroups);
/*Now we held only top groups($tmp) and Attributes groups($belongedGroups) only related to a category*/
$attrs = AttributeGroup::with(array('getParentGroup' => function ($query) use($belongedGroups) {
$query->order_by('sort_order', 'ASC');
$query->where_in('id', $belongedGroups);
}, 'getParentGroup.getAttributes'))->where_in('id', $topGroups)->get();
return Response::eloquent($attrs);
}