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