You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.1 KiB

2 years ago
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Madnest\Madzipper\Facades\Madzipper;
class DatabaseRefresh extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'database:refresh';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Refresh database after a certain time';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
Artisan::call('db:wipe');
$sql_path = base_path('installation/database.sql');
DB::unprepared(file_get_contents($sql_path));
File::deleteDirectory('storage/app/public');
Madzipper::make('installation/public.zip')->extractTo('storage/app');
}
}