2019-11-19 23:54:42 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services\Installer;
|
|
|
|
|
|
|
|
use App\Contracts\Service;
|
2019-12-13 04:07:35 +08:00
|
|
|
use Nwidart\Modules\Facades\Module;
|
2019-11-19 23:54:42 +08:00
|
|
|
|
|
|
|
class InstallerService extends Service
|
|
|
|
{
|
|
|
|
private $migrationSvc;
|
|
|
|
private $seederSvc;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $migrationSvc
|
|
|
|
* @param $seederSvc
|
|
|
|
*/
|
|
|
|
public function __construct(MigrationService $migrationSvc, SeederService $seederSvc)
|
|
|
|
{
|
|
|
|
$this->migrationSvc = $migrationSvc;
|
|
|
|
$this->seederSvc = $seederSvc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check to see if there is an upgrade pending by checking the migrations or seeds
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isUpgradePending(): bool
|
|
|
|
{
|
|
|
|
if (count($this->migrationSvc->migrationsAvailable()) > 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->seederSvc->seedsPending()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2019-12-13 04:07:35 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable the installer and importer modules
|
|
|
|
*/
|
|
|
|
public function disableInstallerModules()
|
|
|
|
{
|
|
|
|
$module = Module::find('installer');
|
|
|
|
$module->disable();
|
|
|
|
|
|
|
|
$module = Module::find('importer');
|
|
|
|
$module->disable();
|
|
|
|
}
|
2019-11-19 23:54:42 +08:00
|
|
|
}
|