fix reset-app

This commit is contained in:
Mohit Panjwani
2020-12-15 21:02:22 +05:30
parent 13fe38517c
commit 34f252b1c9

View File

@ -3,17 +3,20 @@
namespace Crater\Console\Commands; namespace Crater\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
class ResetApp extends Command class ResetApp extends Command
{ {
use ConfirmableTrait;
/** /**
* The name and signature of the console command. * The name and signature of the console command.
* *
* @var string * @var string
*/ */
protected $signature = 'reset:app'; protected $signature = 'reset:app {--force}';
/** /**
* The console command description. * The console command description.
@ -39,13 +42,28 @@ class ResetApp extends Command
*/ */
public function handle() public function handle()
{ {
if ($this->confirm('Do you wish to continue? This will delete your tables')) { if (!$this->confirmToProceed()) {
Artisan::call('migrate:reset --force'); return;
\Storage::disk('local')->delete('database_created');
// $file = new Filesystem;
// $file->cleanDirectory('public/storage');
} }
$this->info('Running migrate:fresh');
Artisan::call('migrate:fresh --seed --force');
$this->info('Seeding database');
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
$path = base_path('.env');
if (file_exists($path)) {
file_put_contents($path, str_replace(
'APP_DEBUG=true',
'APP_DEBUG=false',
file_get_contents($path)
));
}
$this->info('App has been reset successfully');
} }
} }