本文整理汇总了PHP中ProductCategory::select方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::select方法的具体用法?PHP ProductCategory::select怎么用?PHP ProductCategory::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductCategory
的用法示例。
在下文中一共展示了ProductCategory::select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCategoryDetails
public function getCategoryDetails($cat_id)
{
$category_details = array();
$cat_details = ProductCategory::select('category_name', 'parent_category_id', 'id')->whereRaw('id = ?', array($cat_id))->first();
if (count($cat_details) > 0) {
$cat_details['full_parent_category_name'] = $this->getParentCategoryName($cat_details['id']);
$category_details = $cat_details;
}
return $category_details;
}
示例2: listProductCategory
public function listProductCategory()
{
if (!Request::ajax()) {
return App::abort(404);
}
$start = Input::has('start') ? (int) Input::get('start') : 0;
$length = Input::has('length') ? Input::get('length') : 10;
$search = Input::has('search') ? Input::get('search') : [];
$productCategories = ProductCategory::select('categories.id', 'categories.name', 'categories.menu_id', 'categories.active', 'parent.name as parent_name')->leftJoin('categories as parent', 'categories.parent_id', '=', 'parent.id')->with('images');
if (!empty($search)) {
foreach ($search as $key => $value) {
if (empty($value)) {
continue;
}
if ($key == 'active' || $key == 'on_menu') {
if ($value == 'yes') {
$value = 1;
} else {
$value = 0;
}
if ($key == 'active') {
$productCategories->where('categories.' . $key, $value);
} else {
$productCategories->where('categories.menu_id', '>', 0);
}
} else {
if ($key == 'parent_id') {
$productCategories->where('categories.' . $key, (int) $value);
} else {
$value = ltrim(rtrim($value));
$productCategories->where('categories.' . $key, 'like', '%' . $value . '%');
}
}
}
}
$order = Input::has('order') ? Input::get('order') : [];
if (!empty($order)) {
$columns = Input::has('columns') ? Input::get('columns') : [];
foreach ($order as $value) {
$column = $value['column'];
if (!isset($columns[$column]['name']) || empty($columns[$column]['name'])) {
continue;
}
$productCategories->orderBy('categories.' . $columns[$column]['name'], $value['dir'] == 'asc' ? 'asc' : 'desc');
}
}
$count = $productCategories->count();
if ($length > 0) {
$productCategories = $productCategories->skip($start)->take($length);
}
$arrProductCategories = $productCategories->get()->toArray();
$arrReturn = ['draw' => Input::has('draw') ? Input::get('draw') : 1, 'recordsTotal' => ProductCategory::count(), 'recordsFiltered' => $count, 'data' => []];
if (!empty($arrProductCategories)) {
foreach ($arrProductCategories as $productCategory) {
$image = '';
if (!empty($productCategory['images'])) {
$image = reset($productCategory['images']);
$image = $image['path'];
}
$arrReturn['data'][] = array(++$start, $productCategory['id'], $productCategory['name'], $productCategory['parent_name'], $image, $productCategory['menu_id'] ? 1 : 0, $productCategory['active']);
}
}
$response = Response::json($arrReturn);
$response->header('Content-Type', 'application/json');
return $response;
}