vendredi 1 mai 2020

laravel 5.2 pass variable in all controllers

can someone help please, i want to make my varaibles global in all controllers without every time create instance.. settings = new Setting(); settings has only one row.

class Controller extends BaseController

protected $settings;

    public function __construct() 
    {
        $this->settings = Setting::all();
        View::share('settings', $this->settings);
    }
}

and in another controller i use :

$this->settings->email;

but it does not work, please i search and see this method is not good, can someone please give me a good approach for this, laravel 5.2.

thanks so much..!!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire