本文整理汇总了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;
}
}