mercredi 2 septembre 2015

Accessing a Model from ConfigServiceProvider not working in Laravel

I am trying to get all database values from the Configs database table into the ConfigServiceProvider, to reuse those variables in all blades throughout the site. But I keep on getting an error "Call to a member function connection() on null". Can it be that I cannot do database queries from a provider?

use Illuminate\Support\ServiceProvider;
use App\Models\Config;

class ConfigServiceProvider extends ServiceProvider {

    public function register() {
        $globals = Config::all();
        print_r($globals);
    }

}

If so, how do I do this then?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1L58tX2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire