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