“Crie função global Laravel” Respostas de código

Como declarar variável global no controlador de Laravel

class TestController extends Controller
{
    private $x;

    public function index()
    {
        $this->x ='22';
    }

    public function send_message()
    {
        echo $this->x;
    }
}
Funky Dev

Crie função global Laravel

 //Into the console
 php artisan clear-compiled
 php artisan config:cache
Ben10

Crie função global Laravel

Composer //Autload whitin composer.json method
|
|--->Laravel App //My method
     |
     |--->Controller //Trait method
     |--->Blade //Trait method
     |--->Listener //Trait method
     |--->...
Ben10

Crie função global Laravel

 //App\Config\App.php

 'providers' => [

     /*
     * Laravel Framework Service Providers...
     */
     Illuminate\Auth\AuthServiceProvider::class,
     ...
     Illuminate\Validation\ValidationServiceProvider::class,
     Illuminate\View\ViewServiceProvider::class,
     App\Providers\GlobalFunctionsServiceProvider::class, //Add your service provider
Ben10

Crie função global Laravel

 //Into the console
 php artisan make:provider GlobalFunctionsServiceProvider
Ben10

Respostas semelhantes a “Crie função global Laravel”

Perguntas semelhantes a “Crie função global Laravel”

Mais respostas relacionadas para “Crie função global Laravel” em PHP

Procure respostas de código populares por idioma

Procurar outros idiomas de código