Answers for "set global variable laravel"

PHP
0

laravel use global variable in model

SET configuration variables at runtime:
class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        View::share('key', 'value');
        Schema::defaultStringLength(191);
        $company=DB::table('company')->where('id',1)->first();
        config(['yourconfig.company' => $company]);
    }
}

USE:
config('yourconfig.company');
Posted by: Guest on October-13-2020
0

global variable in laravel controller

private $variable;
Posted by: Guest on September-24-2020
0

create global function laravel

//AppConfigApp.php

 'providers' => [

     /*
     * Laravel Framework Service Providers...
     */
     IlluminateAuthAuthServiceProvider::class,
     ...
     IlluminateValidationValidationServiceProvider::class,
     IlluminateViewViewServiceProvider::class,
     AppProvidersGlobalFunctionsServiceProvider::class, //Add your service provider
Posted by: Guest on September-21-2021
0

create global function laravel

//Use your function anywhere within your Laravel app
 first_function();
 second_function();
Posted by: Guest on September-21-2021

Browse Popular Code Answers by Language