當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Category::getParents方法代碼示例

本文整理匯總了PHP中app\Category::getParents方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::getParents方法的具體用法?PHP Category::getParents怎麽用?PHP Category::getParents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Category的用法示例。


在下文中一共展示了Category::getParents方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: index

 /**
  * Display a listing of categories and the category members (parent-children) and their social media.
  *
  * @return Response
  */
 public function index($slug)
 {
     // get links in footer
     $linksArr = \App\Links::orderBy('rank', 'ASC')->lists('link', 'name');
     if ($slug != 'all') {
         $catObj = Category::whereSlug($slug)->first();
         if (is_null($catObj)) {
             \Session::flash('message', 'Invalid category');
             return redirect('/socialmedia/all');
         }
         $catPathArr = $catObj->getCategoryPath($slug);
         $catArr = $catObj->getChildren($catObj->id);
     } else {
         $catPathArr = array();
         $catObj = new Category();
         $catArr = $catObj->getParents();
     }
     $getChildren = $this->getChildrenBool($catPathArr, $slug, $catObj);
     // eg. get the teammates on the Lakers, don't get teams in the Pacific Coast division
     if ($getChildren) {
         $memberArr = $this->memberObj->getMembersWithinSingleCategory($catObj->id);
         list($memberArr, $contentArr) = $this->memberSocialObj->getSocialMediaWithMemberIds($memberArr);
         return view('socialmedia.child', compact('memberArr', 'contentArr', 'catPathArr', 'linksArr'));
     } else {
         $parentArr['contentArr'] = [];
         foreach ($catArr as $catId => $catName) {
             $memberArr = $this->memberObj->getMembersWithinSingleCategory($catId);
             $tmpMemberArr = array($memberArr[0]);
             list(, $contentArr) = $this->memberSocialObj->getSocialMediaWithMemberIds($tmpMemberArr);
             $parentArr['memberArr'][$catId] = $memberArr;
             $parentArr['contentArr'] = $parentArr['contentArr'] + $contentArr;
         }
         return view('socialmedia.parent', compact('parentArr', 'catArr', 'catPathArr', 'linksArr'));
     }
 }
開發者ID:nowarena,項目名稱:homestead,代碼行數:40,代碼來源:SocialMediaController.php

示例2: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  Categories $category
  * @return Response
  */
 public function edit(Category $category)
 {
     $parentIdNameArr = Category::getParents();
     $selectedParentIdNameArr = CategoryParentAndChildren::getSelectedParentIdNameArr($category->id);
     $ddArr = CategoryParentAndChildren::makeDDArr($parentIdNameArr, $selectedParentIdNameArr, $category->id);
     return view('categories.edit', compact('category', 'ddArr', 'selectedParentIdNameArr'));
 }
開發者ID:nowarena,項目名稱:laravel,代碼行數:13,代碼來源:CategoriesController.php

示例3: getHierarchy

 public function getHierarchy()
 {
     $parentChildArr = array();
     $categoryModel = new Category();
     $parentArr = $categoryModel->getParents();
     foreach ($parentArr as $id => $name) {
         //$parentChildArr[] = array('parent_id' => 0, 'child_id' => $id);
     }
     $categoriesParentAndChildrenArr = $this->all();
     foreach ($categoriesParentAndChildrenArr as $key => $obj) {
         $tmp = $obj->getAttributes();
         $parentChildArr[] = array('parent_id' => $tmp['parent_id'], 'child_id' => $tmp['child_id']);
     }
     $tree = $this->buildTree($parentChildArr);
     return $tree;
 }
開發者ID:nowarena,項目名稱:homestead,代碼行數:16,代碼來源:CategoryParentAndChildren.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int  Categories $category
  * @return Response
  */
 public function show(Category $categoryObj)
 {
     $parentCatArr = $categoryObj->getParents();
     return view('categories.show', compact('categoryObj', 'parentCatArr'));
 }
開發者ID:nowarena,項目名稱:homestead,代碼行數:11,代碼來源:CategoriesController.php


注:本文中的app\Category::getParents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。