2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
2017-01-30 20:40:43 +01:00
|
|
|
use Utils;
|
2017-05-01 14:46:57 +02:00
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
2017-01-30 20:40:43 +01:00
|
|
|
* Class ResetData.
|
2016-07-03 18:11:58 +02:00
|
|
|
*/
|
|
|
|
class ResetData extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $name = 'ninja:reset-data';
|
2017-05-01 14:17:52 +02:00
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Reset data';
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
public function fire()
|
|
|
|
{
|
2017-10-24 09:59:26 +02:00
|
|
|
$this->info(date('r') . ' Running ResetData...');
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2017-01-30 20:40:43 +01:00
|
|
|
if (! Utils::isNinjaDev()) {
|
2016-07-03 18:11:58 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2017-05-01 14:17:52 +02:00
|
|
|
if ($database = $this->option('database')) {
|
|
|
|
config(['database.default' => $database]);
|
|
|
|
}
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
Artisan::call('migrate:reset');
|
|
|
|
Artisan::call('migrate');
|
|
|
|
Artisan::call('db:seed');
|
|
|
|
}
|
2017-05-01 14:17:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function getOptions()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['fix', null, InputOption::VALUE_OPTIONAL, 'Fix data', null],
|
|
|
|
['client_id', null, InputOption::VALUE_OPTIONAL, 'Client id', null],
|
|
|
|
['database', null, InputOption::VALUE_OPTIONAL, 'Database', null],
|
|
|
|
];
|
|
|
|
}
|
2017-01-30 17:05:31 +01:00
|
|
|
}
|