I would like to create a global variable in laravel to be able to use it in controllers as in views; I would like to do this without having to use Session
or Cache
. Is there any colleagues mechanism? Investigating I realize that in AppServiceProvider
I can create one like this that believes:
view()->composer('*', function($view){
$view->with('is_lock', LockSession::isLocked());
});
This variable that I create only serves for the views or it also helps me to call it in my controllers