In laravel 5.8 app I need tofill config values from databse setting and for this I do in app/Providers/AppServiceProvider.php :
public function boot()
{
$request= request();
if ( \Schema::hasTable(with( new Settings)->getTable() ) ) {
$settingsArray = Settings::getSettingsList(['site_name', 'site_heading', 'noreply_email'], -1, __FILE__, __LINE__);
$site_name = !empty($settingsArray['site_name']) ? $settingsArray['site_name'] : '';
$site_heading = !empty($settingsArray['site_heading']) ? $settingsArray['site_heading'] : '';
$noreply_email = !empty($settingsArray['noreply_email']) ? $settingsArray['noreply_email'] : '';
config(['feed.feeds.main.title' => htmlspecialchars_decode($site_name . ' : ' . $site_heading)]);
config(['mail.from.name' => htmlspecialchars_decode($site_name . ' support')]);
config(['mail.from.address' => htmlspecialchars_decode($noreply_email)]);
}
It works ok, but not when I install my app on server, it looks like that there is reference to boot method above while running
composer install
and I got database error, as I have no .env file yet. If to comment the code above all installation works ok. If there is some proper way for additive checking, like if key was generated here?
Thanks!
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2YtLFzl
via IFTTT
Aucun commentaire:
Enregistrer un commentaire