本文整理匯總了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'));
}