vito/app/Jobs/Site/ChangePHPVersion.php
Saeed Vaziry 5c72f12490 init
2023-07-02 12:47:50 +02:00

44 lines
994 B
PHP

<?php
namespace App\Jobs\Site;
use App\Events\Broadcast;
use App\Jobs\Job;
use App\Models\Site;
class ChangePHPVersion extends Job
{
protected Site $site;
protected string $version;
public function __construct(Site $site, $version)
{
$this->site = $site;
$this->version = $version;
}
public function handle(): void
{
$this->site->php_version = $this->version;
$this->site->server->webserver()->handler()->changePHPVersion($this->site, $this->version);
$this->site->save();
event(
new Broadcast('change-site-php-finished', [
'id' => $this->site->id,
'php_version' => $this->site->php_version,
])
);
}
public function failed(): void
{
event(
new Broadcast('change-site-php-failed', [
'message' => __('Failed to change PHP!'),
'id' => $this->site->id,
])
);
}
}