我需要一些幫助來顯示2頁中的所有類別。 現在我將它們顯示在1頁中。我的問題是我怎樣才能在其他頁面顯示他們呢? 這是控制器:如何在2頁上顯示類別
class ShopController extends MainController
{
public function categories(){
self::$data['categories']=Categorie::all()->toArray();
self::$data['title']=self::$data['title'].'| Shop Categories';
return view('content.categories', self::$data);
}
如果我嘗試使用延伸,並從頁面「content.categories」得到它,它說,$類是不確定的。 (所以它只適用於content.categories)
你試圖在由'延伸佈局訪問類別content.categories'? –
是的,但它告訴我的$類別是未定義的 –
嘗試'返回視圖('content.categories') - > withCategories(self :: $ data);'! – Maraboc