“Buat fungsi global Laravel” Kode Jawaban

Cara mendeklarasikan variabel global di Laravel Controller

class TestController extends Controller
{
    private $x;

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

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

Buat fungsi global Laravel

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

Buat fungsi global Laravel

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

Buat fungsi 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

Buat fungsi global Laravel

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

Jawaban yang mirip dengan “Buat fungsi global Laravel”

Pertanyaan yang mirip dengan “Buat fungsi global Laravel”

Lebih banyak jawaban terkait untuk “Buat fungsi global Laravel” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya