invoiceninja/app/Console/Commands/ResetData.php

53 lines
1.1 KiB
PHP
Raw Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Console\Commands;
2015-03-17 07:45:25 +10:00
use Illuminate\Console\Command;
2017-01-30 21:40:43 +02:00
use Utils;
2017-05-01 15:46:57 +03:00
use Symfony\Component\Console\Input\InputOption;
2015-03-17 07:45:25 +10:00
/**
2017-01-30 21:40:43 +02:00
* Class ResetData.
*/
class ResetData extends Command
{
/**
* @var string
*/
protected $name = 'ninja:reset-data';
2017-05-01 15:17:52 +03:00
/**
* @var string
*/
protected $description = 'Reset data';
2015-03-17 07:45:25 +10:00
2019-09-12 19:30:10 -04:00
public function handle()
{
2017-10-24 10:59:26 +03:00
$this->info(date('r') . ' Running ResetData...');
2015-03-17 07:45:25 +10:00
2017-01-30 21:40:43 +02:00
if (! Utils::isNinjaDev()) {
return;
}
2015-03-17 07:45:25 +10:00
2017-05-01 15:17:52 +03:00
if ($database = $this->option('database')) {
config(['database.default' => $database]);
}
Artisan::call('migrate:reset');
Artisan::call('migrate');
Artisan::call('db:seed');
}
2017-05-01 15:17:52 +03: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 18:05:31 +02:00
}