Completed
Branch dev4 (2f299a)
by Ron
08:25
created

BackupController::backupNow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Log;
8
use Illuminate\Support\Facades\Storage;
9
use Illuminate\Support\Facades\Artisan;
10
11
class BackupController extends Controller
12
{
13
    //  Only authorized users have access
14
    public function __construct()
15
    {
16
        $this->middleware('auth');
17
    }
18
    
19
    //  Backup landing page
20
    public function index()
21
    {        
22
        return view('installer.backupIndex');
23
    }
24
    
25
    public function loadBackups()
26
    {
27
        $backups = Storage::disk('backup')->files();
28
        
29
        return view('installer.backupShow', [
30
            'backups' => $backups
31
        ]);
32
    }
33
    
34
    //  Manual backup
35
    public function backupNow()
36
    {
37
        Artisan::call('backup:now', [
38
            'type' => 'manual'
39
        ]);
40
        
41
        return 'success';
42
    }
43
    
44
    //  Download an existing backup
45
    public function downloadBackup($name)
46
    {
47
        return Storage::disk('backup')->download($name);
48
    }
49
    
50
    //  Delete a backup
51
    public function deleteBackup($name)
52
    {
53
        Storage::disk('backup')->delete($name);
54
        return 'success';
55
    }
56
}
57