coolify/app/Http/Livewire/Project/Application/Deployments.php

45 lines
1.2 KiB
PHP
Raw Normal View History

2023-05-24 14:26:50 +02:00
<?php
namespace App\Http\Livewire\Project\Application;
use App\Models\Application;
use Livewire\Component;
class Deployments extends Component
{
public int $application_id;
public $deployments = [];
2023-05-31 14:57:42 +02:00
public int $deployments_count = 0;
2023-05-24 14:26:50 +02:00
public string $current_url;
2023-05-31 14:24:20 +02:00
public int $skip = 0;
public int $default_take = 8;
2023-06-02 12:34:45 +02:00
public bool $show_next = false;
2023-05-31 14:24:20 +02:00
2023-05-24 14:26:50 +02:00
public function mount()
{
$this->current_url = url()->current();
}
2023-05-31 14:24:20 +02:00
public function reload_deployments()
2023-05-24 14:26:50 +02:00
{
2023-05-31 14:24:20 +02:00
$this->load_deployments();
2023-05-24 14:26:50 +02:00
}
2023-05-31 14:24:20 +02:00
public function load_deployments(int|null $take = null)
2023-05-24 14:26:50 +02:00
{
2023-05-31 14:24:20 +02:00
if ($take) {
$this->skip = $this->skip + $take;
}
$take = $this->default_take;
2023-05-31 14:57:42 +02:00
['deployments' => $deployments, 'count' => $count] = Application::find($this->application_id)->deployments($this->skip, $take);
$this->deployments = $deployments;
$this->deployments_count = $count;
2023-06-02 12:34:45 +02:00
if (count($this->deployments) !== 0) {
$this->show_next = true;
if (count($this->deployments) < $take) {
$this->show_next = false;
}
2023-05-31 14:24:20 +02:00
return;
}
2023-05-24 14:26:50 +02:00
}
}