Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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');
 
PREVIOUS NEXT
Tagged: #appserviceprovider #laravel #share #common #settings #controllers
ADD COMMENT
Topic
Name
5+1 =