namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
// Example global data
$globalData = [
'app_theme' => 'dark', // Current app theme
'api_limit' => 100, // API request limit
];
// Share data with all views
View::share('globalData', $globalData);
}
}
Use the shared data in any Blade template: