Skip to content

Commit

Permalink
Merge pull request #19 from Laravel-Backpack/dev-artisanfix
Browse files Browse the repository at this point in the history
[Bug Fix] Prevents DB Queries running when Artisan is running commands
  • Loading branch information
tabacitu authored Dec 7, 2016
2 parents 75dd842 + 669adfa commit e8381be
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/SettingsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,23 @@ class SettingsServiceProvider extends ServiceProvider
*/
public function boot()
{
// only use the Settings package if the Settings table is present in the database
if (count(Schema::getColumnListing('settings'))) {
// get all settings from the database
$settings = Setting::all();
if (!\App::runningInConsole()) {
// only use the Settings package if the Settings table is present in the database
if (count(Schema::getColumnListing('settings'))) {
// get all settings from the database
$settings = Setting::all();

// bind all settings to the Laravel config, so you can call them like
// Config::get('settings.contact_email')
foreach ($settings as $key => $setting) {
Config::set('settings.'.$setting->key, $setting->value);
// bind all settings to the Laravel config, so you can call them like
// Config::get('settings.contact_email')
foreach ($settings as $key => $setting) {
Config::set('settings.'.$setting->key, $setting->value);
}
}
}

// publish the migrations and seeds
$this->publishes([__DIR__.'/database/migrations/' => database_path('migrations')], 'migrations');
$this->publishes([__DIR__.'/database/seeds/' => database_path('seeds')], 'seeds');
// publish the migrations and seeds
$this->publishes([__DIR__.'/database/migrations/' => database_path('migrations')], 'migrations');
$this->publishes([__DIR__.'/database/seeds/' => database_path('seeds')], 'seeds');
}
}

/**
Expand Down

0 comments on commit e8381be

Please sign in to comment.