Merge pull request #1829 from CachetHQ/fix-config-seeding

Fix clearing of configs when seeding
This commit is contained in:
Graham Campbell
2016-05-25 20:30:30 +01:00
2 changed files with 36 additions and 3 deletions

View File

@@ -17,9 +17,9 @@ use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Models\Setting;
use CachetHQ\Cachet\Models\Subscriber;
use CachetHQ\Cachet\Models\User;
use CachetHQ\Cachet\Settings\Repository;
use DateInterval;
use DateTime;
use Illuminate\Console\Command;
@@ -49,6 +49,27 @@ class DemoSeederCommand extends Command
*/
protected $description = 'Seeds Cachet with demo data.';
/**
* The settings repository.
*
* @var \CachetHQ\Cache\Settings\Repository
*/
protected $settings;
/**
* Create a new demo seeder command instance.
*
* @param \CachetHQ\Cache\Settings\Repository $settings
*
* @return void
*/
public function __construct(Repository $settings)
{
parent::__construct();
$this->settings = $settings;
}
/**
* Execute the console command.
*
@@ -325,10 +346,10 @@ EINCIDENT;
],
];
Setting::truncate();
$this->settings->clear();
foreach ($defaultSettings as $setting) {
Setting::create($setting);
$this->settings->set($setting['name'], $setting['value']);
}
}

View File

@@ -90,6 +90,18 @@ class Repository
$this->model->where('name', $name)->delete();
}
/**
* Clear all settings.
*
* @return void
*/
public function clear()
{
$this->stale = true;
$this->model->query()->delete();
}
/**
* Is the config state stale?
*