| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 39 | public function handle() |
||
| 40 | { |
||
| 41 | $path = storage_path('dump.sql'); |
||
| 42 | |||
| 43 | $config = config('database'); |
||
| 44 | |||
| 45 | $default = $config['default']; |
||
| 46 | $connection = $config['connections'][$default]; |
||
| 47 | |||
| 48 | $process = new Process('mysqldump --host=' . $connection['host'] . ' --user=' . $connection['username'] . ' --password=' . $connection['password'] . ' ' . $connection['database'] . ' > ' . $path); |
||
| 49 | $process->run(); |
||
| 50 | |||
| 51 | // executes after the command finishes |
||
| 52 | if (!$process->isSuccessful()) { |
||
| 53 | throw new ProcessFailedException($process); |
||
| 54 | } |
||
| 55 | |||
| 56 | $this->info('Database backup saved to: ' . storage_path('dump.sql')); |
||
| 57 | } |
||
| 58 | } |
||
| 59 |