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..!!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2VSEAsU
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

I am unable to figure out how to create payment collection request, after a form has been submitted in laravel

laravel, mysql transaction not working after failed one time