本文整理汇总了PHP中ProductCategory::getSource方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::getSource方法的具体用法?PHP ProductCategory::getSource怎么用?PHP ProductCategory::getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductCategory
的用法示例。
在下文中一共展示了ProductCategory::getSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editProduct
public function editProduct($productId)
{
try {
$product = Product::with('images')->with('categories')->with('optionGroups')->with('options')->with('priceBreaks')->with('sizeLists')->findorFail($productId);
} catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return App::abort(404);
}
$product = $product->toArray();
foreach (['option_groups', 'options'] as $value) {
$tmpData = [];
if (!empty($product[$value])) {
foreach ($product[$value] as $v) {
$tmpData[] = $v['id'];
}
}
$product[$value] = $tmpData;
unset($tmpData);
}
$product['sell_price'] = number_format($product['sell_price'], 2);
$arrCategories = [];
if (!empty($product['categories'])) {
foreach ($product['categories'] as $category) {
$arrCategories[] = $category['id'];
}
}
$this->layout->title = 'Edit Product';
$this->layout->content = View::make('admin.products-one')->with(['product' => $product, 'arrCategories' => ProductCategory::getSource(false, 0, true), 'arrChosenCategories' => $arrCategories, 'types' => ProductType::getSource(), 'option_groups' => ProductOptionGroup::getSource(false, true), 'layouts' => array()]);
}
示例2: editProductCategory
public function editProductCategory($id)
{
try {
$category = ProductCategory::with('images')->findorFail($id);
} catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return App::abort(404);
}
$category = $category->toArray();
$category['images'] = reset($category['images']);
$this->layout->title = 'Edit Product Category';
$this->layout->content = View::make('admin.product-categories-one')->with(['category' => $category, 'parent' => ProductCategory::getSource(false, $id)]);
}