1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Turahe\LaravelInstaller\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\View\View; |
6
|
|
|
use Illuminate\Routing\Controller; |
7
|
|
|
use Illuminate\Http\RedirectResponse; |
8
|
|
|
use Turahe\LaravelInstaller\Helpers\DatabaseManager; |
9
|
|
|
use Turahe\LaravelInstaller\Helpers\MigrationsHelper; |
10
|
|
|
use Turahe\LaravelInstaller\Helpers\InstalledFileManager; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class UpdateController. |
14
|
|
|
*/ |
15
|
|
|
class UpdateController extends Controller |
16
|
|
|
{ |
17
|
|
|
use MigrationsHelper; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Display the updater welcome page. |
21
|
|
|
* |
22
|
|
|
* @return View |
23
|
|
|
*/ |
24
|
|
|
public function welcome(): View |
25
|
|
|
{ |
26
|
|
|
return view('installer::update.welcome'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Display the updater overview page. |
31
|
|
|
* |
32
|
|
|
* @return View |
33
|
|
|
*/ |
34
|
|
|
public function overview(): View |
35
|
|
|
{ |
36
|
|
|
$migrations = $this->getMigrations(); |
37
|
|
|
$dbMigrations = $this->getExecutedMigrations(); |
38
|
|
|
|
39
|
|
|
return view('installer::update.overview', ['numberOfUpdatesPending' => count($migrations) - count($dbMigrations)]); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Migrate and seed the database. |
44
|
|
|
* |
45
|
|
|
* @return RedirectResponse |
46
|
|
|
*/ |
47
|
|
|
public function database(): RedirectResponse |
48
|
|
|
{ |
49
|
|
|
$databaseManager = new DatabaseManager; |
50
|
|
|
$response = $databaseManager->migrateAndSeed(); |
51
|
|
|
|
52
|
|
|
return redirect()->route('LaravelUpdater::final') |
53
|
|
|
->with(['message' => $response]); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Update installed file and display finished view. |
58
|
|
|
* |
59
|
|
|
* @param InstalledFileManager $fileManager |
60
|
|
|
* @return View |
61
|
|
|
*/ |
62
|
|
|
public function finish(InstalledFileManager $fileManager) |
63
|
|
|
{ |
64
|
|
|
$fileManager->update(); |
65
|
|
|
|
66
|
|
|
return view('installer::update.finished'); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|