vendredi 28 juillet 2017

Laravel 5: How can I load database values into the config/services.php file?

I have a multi-tenant app I'm working on and while adding the socialite package, I tried to load the custom facebook client_id and client_secret for the specific website from the database. I can't really use the env variables because each site will have it's own custom facebook keys.

It seems you can really call a model's method on the config/services.php file because it might not have been loaded yet. I've tried going through the request lifecycle docs to resolve this to no avail.

I've also tried to create a service provider to get the value from my Business model's method and set it as a constant but still, by the time it's available in the app, the config/services.php file has been loaded.

Here's where I want the database value available:

config/services.php

'facebook' => [
  'client_id' => \App\Business::getAppKeys()->fb_client_id,
  'client_secret' => 'your‐fb‐app‐secret',
  'redirect' => 'http://your‐callback‐url',
],

Error:

Fatal error: Call to a member function connection() on null



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire