appserviceprovider laravel share common settings for all controllers

Solutions on MaxInterview for appserviceprovider laravel share common settings for all controllers by the best coders in the world

showing results for - "appserviceprovider laravel share common settings for all controllers"
Valentina
17 Aug 2019
1//in app/Providers/AppServiceProvider.php
2//  Add inside the boot() method
3\App::singleton('general_settings', function(){
4        return Setting::all();
5    });
6	
7//To share with all views to be accessible as $general_settings
8view()->share('general_settings',app('general_settings'));
9
10//To access anywhere else including Controllers/Models
11$general_settings = app('general_settings');