Skip to content

Commit 3bf7da4

Browse files
committed
Make inactiveMigrations() array reusable within controller
1 parent 0b53b3f commit 3bf7da4

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

src/Controllers/InstallController.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
class InstallController extends Controller
2020
{
2121
public $migrations_tables = [];
22+
public $inactive_migrations = false;
23+
public $a_inactive_migrations = [];
2224

2325
public function __construct()
2426
{
@@ -65,12 +67,9 @@ public function index()
6567

6668
$inactive_migrations = $this->inactiveMigrations();
6769

68-
if (count($this->migrations_tables) == count($inactive_migrations)
69-
|| in_array('2017_12_25_222719_update_panichd_priorities_add_position', $this->inactiveMigrations())
70-
) {
70+
if (!$this->isInstalled()) {
7171
// Panic Help Desk is not installed yet
7272

73-
$inactive_migrations = $this->inactiveMigrations();
7473
$previous_ticketit = Schema::hasTable('ticketit_settings');
7574

7675
$quickstart = true;
@@ -100,6 +99,18 @@ public function index()
10099
}
101100
}
102101
}
102+
103+
/**
104+
* Check if PanicHD is installed
105+
*
106+
* @Return bool
107+
*/
108+
public function isInstalled()
109+
{
110+
return (class_exists('Kordy\Ticketit\TicketitServiceProvider')
111+
|| count($this->migrations_tables) == count($this->inactiveMigrations())
112+
|| in_array('2017_12_25_222719_update_panichd_priorities_add_position', $this->inactiveMigrations()) ) ? false : true;
113+
}
103114

104115
/*
105116
* Installation setup
@@ -283,7 +294,10 @@ public function allFilesList($dir_path)
283294
*/
284295
public function inactiveMigrations()
285296
{
286-
$inactiveMigrations = [];
297+
if ($this->inactive_migrations){
298+
return $this->a_inactive_migrations;
299+
}
300+
$inactiveMigrations = [];
287301
$migration_arr = [];
288302

289303
// Package Migrations
@@ -301,7 +315,8 @@ public function inactiveMigrations()
301315
$inactiveMigrations[] = $table;
302316
}
303317
}
304-
318+
$this->inactive_migrations = true;
319+
$this->a_inactive_migrations = $inactiveMigrations;
305320
return $inactiveMigrations;
306321
}
307322

0 commit comments

Comments
 (0)