category; // if ($category->childrens->isEmpty()) { // $parent = $category->parent; // } // $advert = Advert::where('category_id',73)->first(); $categories = $article->categories; $parent = []; foreach ($categories as $category) { $top = getTopCate($category->id); $parent[] = $top->id; } return view('article.show', compact('article', 'parent')); // return view('article.show', compact('article', 'parent', 'category','advert')); } }