Trying to fire the following Eloquent query in a custom config file which is present in: /config
directory in Laravel 5:
'array_name' =>(App\MyApp\Models\ModelName::lists('column_name', 'column_name')),
Getting the following error:
Fatal error: Call to a member function connection() on a non-object in /path/to/the/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 3132
The config files that depend on database must be loaded lazily. Just put them inside a new
config.lazy
folder next toconfig
folder and add the following method inside yourapp/Providers/COnfigServiceProvider.php