phpvms/app/Services/Installer/InstallerService.php
Nabeel S 12848091a2
Laravel 9 Update (#1413)
Update to Laravel 9 and PHP 8+

Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
2022-03-14 11:45:18 -04:00

53 lines
1.3 KiB
PHP

<?php
namespace App\Services\Installer;
use App\Contracts\Service;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Log;
class InstallerService extends Service
{
private MigrationService $migrationSvc;
private SeederService $seederSvc;
/**
* @param MigrationService $migrationSvc
* @param SeederService $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
{
$pendingMigrations = count($this->migrationSvc->migrationsAvailable());
if ($pendingMigrations > 0) {
Log::info('Found '.$pendingMigrations.' pending migrations, update available');
return true;
}
if ($this->seederSvc->seedsPending()) {
Log::info('Found seeds pending, update available');
return true;
}
return false;
}
/**
* Clear whatever caches we can by calling Artisan
*/
public function clearCaches(): void
{
Artisan::call('optimize:clear');
}
}