Here is my app.php
code where I use AppServiceProvider :
/*
* Application Service Providers...
*/
'App\Providers\AppServiceProvider',
'App\Providers\BusServiceProvider',
'App\Providers\ConfigServiceProvider',
'App\Providers\EventServiceProvider',
'App\Providers\RouteServiceProvider',
And here is my AppServiceProvider boot function. I want to use $a
in pages.companyname
page. I'm trying to do this so I can use that value on every page:
public function boot()
{
//
$a = 10;
view()->composer('pages.companyname', function($view)
{
$view->with('latest', $a);
});
}
This is my pages/companyname.blade.php page :
{!! $latest !!}
But It's showing this error
"Undefined variable: latest "
I followed this example
How can I solve this? I want to use one variable across my pages..
N.B : Now $a is a demo variable. I will replace it by SQL query.