lasthourcloud/app/Http/Livewire/Project/Application/PollDeployment.php

31 lines
892 B
PHP
Raw Normal View History

<?php
2023-04-25 09:01:56 +00:00
namespace App\Http\Livewire\Project\Application;
2023-05-03 05:15:45 +00:00
use App\Enums\ActivityTypes;
use Livewire\Component;
2023-03-31 11:32:07 +00:00
use Spatie\Activitylog\Models\Activity;
2023-04-25 09:01:56 +00:00
class PollDeployment extends Component
{
public $activity;
public $isKeepAliveOn = true;
2023-03-31 11:32:07 +00:00
public $deployment_uuid;
public function polling()
{
2023-03-31 11:32:07 +00:00
if ( is_null($this->activity) && isset($this->deployment_uuid)) {
2023-05-03 05:15:45 +00:00
$this->activity = Activity::query()
->where('properties->type', '=', ActivityTypes::DEPLOYMENT->value)
->where('properties->type_uuid', '=', $this->deployment_uuid)
2023-03-31 11:32:07 +00:00
->first();
} else {
$this->activity?->refresh();
}
if (data_get($this->activity, 'properties.status') == 'finished' || data_get($this->activity, 'properties.status') == 'failed' ) {
$this->isKeepAliveOn = false;
}
}
}