Answers for "appserviceprovider laravel share common settings for all controllers"

PHP
0

appserviceprovider laravel share common settings for all controllers

//in app/Providers/AppServiceProvider.php
//  Add inside the boot() method
\App::singleton('general_settings', function(){
        return Setting::all();
    });
	
//To share with all views to be accessible as $general_settings
view()->share('general_settings',app('general_settings'));

//To access anywhere else including Controllers/Models
$general_settings = app('general_settings');
Posted by: Guest on June-27-2021

Code answers related to "appserviceprovider laravel share common settings for all controllers"

Browse Popular Code Answers by Language