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