当前位置: 首页>>代码示例>>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;未经允许,请勿转载。