//create a service provider
php artisan make:provider ComposerServiceProvider
//register the app service provider in providers array of config/app.php
AppProvidersComposerServiceProvider::class,
//pass the data you want to share in views
<?php
namespace AppProviders;
use IlluminateSupportFacadesView;
use IlluminateSupportServiceProvider;
class ComposerServiceProvider extends ServiceProvider {
public function boot()
{
View::composer('*', function($view){
$data = Some logic here ; //eg User::all();
$view->with('data', $data); // 'data' is value to be used in views 'data' = $data
});
}
public function register()
{
//
}
}