Skip to content
Advertisement

Laravel 5.7: A facade root has not been set

I’m trying to get sitewide global settings from the database and use those settings in my controllers.

In order to do this I’ve created a custom global.php file under config directory.
Defined key=>value pairs.
Tried to get values using DB::table(….) facade.

But it returns this error:

A facade root has not been set.

I cannot get past beyond this.

config.php file as follows:

JavaScript

Advertisement

Answer

You can use it

JavaScript

Then in controller you can use config('global.site_on')

Also you can use one query not three

JavaScript

Or more shortly code is

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement