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

42 lines
1.0 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 = [];
public string $current_url;
2023-05-31 14:24:20 +02:00
public int $skip = 0;
public int $default_take = 8;
public bool $show_next = true;
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
ray('Take' . $take);
if ($take) {
ray('Take is not null');
$this->skip = $this->skip + $take;
}
$take = $this->default_take;
$this->deployments = Application::find($this->application_id)->deployments($this->skip, $take);
if (count($this->deployments) !== 0 && count($this->deployments) < $take) {
$this->show_next = false;
return;
}
2023-05-24 14:26:50 +02:00
}
}