本文整理匯總了PHP中app\Category::get_categories_by_parent_id方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::get_categories_by_parent_id方法的具體用法?PHP Category::get_categories_by_parent_id怎麽用?PHP Category::get_categories_by_parent_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Category
的用法示例。
在下文中一共展示了Category::get_categories_by_parent_id方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get_all_childs
public function get_all_childs($cat_id)
{
// $user_info = Auth::user()->toArray();
// if ($user_info['user_type'] == 2) {
if (count($cat_id) != "") {
$cat = new Category();
$all_childs = array();
$child_category = array();
$child_category_ids = array();
$child_categories = $cat->get_categories_by_parent_id($cat_id);
if ($child_categories != null) {
foreach ($child_categories as $category_question) {
array_push($child_category, $category_question);
array_push($child_category_ids, $category_question['id']);
// array_push($child_category_content, $category_question['title']);
}
$sub_child_category = array();
// $sub_child_category_content = array();
$sub_child_categories = $cat->get_categories_by_parents_id_in($child_category_ids);
if ($sub_child_categories != null) {
foreach ($sub_child_categories as $category_question) {
array_push($sub_child_category, $category_question);
// array_push($sub_child_category_content, $category_question['title']);
}
}
$all_childs = array('child' => $child_category, 'sub_child' => $sub_child_category);
}
return $all_childs;
}
// }
// $message = "you are not admin. you can't use this method";
// return view('welcome')
// ->withMessage($message);
}
示例2: get_all_childs
public function get_all_childs($cat_id)
{
if (!empty($cat_id)) {
$cat = new Category();
$all_childs = array();
$child_category = array();
$child_categories = $cat->get_categories_by_parent_id($cat_id);
if ($child_categories != null) {
foreach ($child_categories as $category_question) {
array_push($child_category, $category_question['id']);
}
$sub_child_category = array();
$sub_child_categories = $cat->get_categories_by_parents_id_in($child_category);
if ($sub_child_categories != null) {
foreach ($sub_child_categories as $category_question) {
array_push($sub_child_category, $category_question['id']);
}
}
$all_childs = array('child' => $child_category, 'sub_child' => $sub_child_category);
}
return $all_childs;
}
}