Files
faveo/app/Console/Commands/DropTables.php
Manish Verma 22d3bb4036 Installer updates
Added probe.php
Added new installer views and controllers
Updated AuthController
Updated Middlewares
Updated Commands for installation process
2018-08-07 13:45:46 +05:30

57 lines
1.2 KiB
PHP

<?php
namespace App\Console\Commands;
use DB;
use Illuminate\Console\Command;
class DropTables extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'droptables';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Drops all tables';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$colname = 'Tables_in_'.env('DB_DATABASE');
$droplist = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
$droplist = implode(',', $droplist);
DB::beginTransaction();
//turn off referential integrity
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
DB::statement("DROP TABLE $droplist");
//turn referential integrity back on
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
DB::commit();
$this->comment(PHP_EOL.'If no errors showed up, all tables were dropped'.PHP_EOL);
}
}