Undefined variable with two View Composer

i am trying to access first_user_name which is defined in the app service provider using view()->composer , but when trying to access the variable getting a error of undefined variable.

The boot Method in app service provider :

  public function boot()
        view()->composer('pages.index', function ($view) {
                'user_first_name' => explode(' ',auth()->user()->name)[0]

        view()->composer(['pages.prices','pages.locate-us'], function ($view) {
                'locations' => Location::all(),
                'addons' => Addon::all()

and the Navbar where i am trying to access the variable :

                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                               Hi, {{user_first_name}}
                            <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                                <a class="dropdown-item" href="#">Action</a>
                                <a class="dropdown-item" href="#">Another action</a>
                                <div class="dropdown-divider"></div>
                                <a class="dropdown-item" href="#">Something else here</a>
                        <li class="nav-item">
                            <a href="/login" class="nav-link">
                                Sign In

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us