Search
 
SCRIPT & CODE EXAMPLE
 

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');
Comment

PREVIOUS NEXT
Code Example
Php :: php get from second character of string to middle 
Php :: difference between guard and fillable laravel 
Php :: php random array name 
Php :: Natural numbers from php 
Php :: php send response without quitting 
Php :: laravel compile blade 
Php :: convert a value to a float in php 
Php :: gd2 image resizing library in codeigniter 
Php :: codeigniter 4 get method deprecated 
Php :: phpmyadmin arch 
Php :: wordpress auto save draft 
Php :: $SERVER get cuurent directior PHP 
Php :: calculate age from date of birth php 
Php :: jupiter/framework/admin/generators/option-generator.php on line 80 
Php :: smarty shorthand if 
Php :: laravel eloquent pass to next element 
Php :: php detect daylight saving time 
Php :: print csv file in php 
Php :: php oops 
Php :: Writing a New Block for Cryptocurrency Blockchain 
Php :: laravel Join columns of Day, Month , Year to calculate age 
Php :: php The function is a conversion from a key to a value 
Php :: PHP: how to "clone from" another object of same class 
Php :: register widget in wordpress 
Php :: get post date and time in wordpress 
Php :: yii relations 
Php :: backend/index.php when deploying 
Php :: Redirect file.php to file with .htaccess | Redirect to its non .php version 
Php :: laravel onclick all notification reads 
Php :: Metabox Array 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =