app/Providers/AppServiceProvider.php
/**
     * Bootstrap any application services.
     *
     * @return void
     */
Bootstrap any application services.
@return void
Bootstrap any application services . @return void
public function boot()
    {
             $sessionId =strtotime(now()).uniqid();
            if(empty(Session('sessionId'))){
                Session(['sessionId' => $sessionId]);
            }
            view()->composer('*', function ($view) {
                $sessionId = Session('sessionId');
                $count = Cart::where(['session_id' => $sessionId])->sum('quantity');
                $view->with('count', $count);
            });
    }
public function boot ( ) { $ sessionId = strtotime ( now ( ) ) . uniqid ( ) ; if ( empty ( Session ( 'sessionId' ) ) ) { Session ( [ 'sessionId' => $ sessionId ] ) ; } view ( ) -> composer ( '*' , function ( $ view ) { $ sessionId = Session ( 'sessionId' ) ; $ count = Cart :: where ( [ 'session_id' => $ sessionId ] ) -> sum ( 'quantity' ) ; $ view -> with ( 'count' , $ count ) ; } ) ; }
Bootstrap any application services.
Bootstrap any application services .