Completed
Push — master ( ff94ff...f5576b )
by Avtandil
04:05
created

DbClear::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 0
dl 0
loc 13
ccs 0
cts 12
cp 0
crap 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of the Laravel Platfourm package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\Platfourm\Foundation\Console;
12
13
use DB;
14
use Longman\Platfourm\Console\Command;
15
16
class DbClear extends Command
17
{
18
    /**
19
     * The name and signature of the console command.
20
     *
21
     * @var string
22
     */
23
    protected $signature = 'db:clear';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = 'Clear database';
31
32
    /**
33
     * Execute the console command.
34
     *
35
     * @return mixed
36
     */
37
    public function handle()
38
    {
39
        DB::statement('SET FOREIGN_KEY_CHECKS=0;');
40
41
        $tables = DB::select('SHOW TABLES');
42
        foreach ($tables as $table) {
43
            foreach ($table as $key => $value) {
44
                DB::statement('DROP TABLE `'.$value.'`');
45
            }
46
        }
47
        DB::statement('SET FOREIGN_KEY_CHECKS=1;');
48
        $this->info('All tables dropped from database!');
49
    }
50
}
51