Mage2\System\ViewComposers\LayoutAppComposer::compose PHP Method

compose() public method

Bind data to the view.
public compose ( Illuminate\View\View $view ) : void
$view Illuminate\View\View
return void
    public function compose(View $view)
    {
        $cart = count(Session::get('cart'));
        $categoryModel = new Category();
        $baseCategories = $categoryModel->getAllCategories();
        $view->with('categories', $baseCategories)->with('cart', $cart);
    }
LayoutAppComposer