mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 07:52:34 +00:00
init
This commit is contained in:
58
app/Http/Livewire/ServerLogs/LogsList.php
Normal file
58
app/Http/Livewire/ServerLogs/LogsList.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerLogs;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Site;
|
||||
use App\Traits\HasCustomPaginationView;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class LogsList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
use HasCustomPaginationView;
|
||||
|
||||
public ?int $count = null;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public ?Site $site = null;
|
||||
|
||||
public string $logContent;
|
||||
|
||||
public function showLog(int $id): void
|
||||
{
|
||||
$log = $this->server->logs()->findOrFail($id);
|
||||
$this->logContent = $log->content;
|
||||
|
||||
$this->dispatchBrowserEvent('open-modal', 'show-log');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
if ($this->site) {
|
||||
return $this->renderSite();
|
||||
}
|
||||
|
||||
if ($this->count) {
|
||||
$logs = $this->server->logs()->latest()->take(10)->get();
|
||||
} else {
|
||||
$logs = $this->server->logs()->latest()->simplePaginate(10);
|
||||
}
|
||||
|
||||
return view('livewire.server-logs.logs-list', compact('logs'));
|
||||
}
|
||||
|
||||
private function renderSite(): View
|
||||
{
|
||||
if ($this->count) {
|
||||
$logs = $this->site->logs()->latest()->take(10)->get();
|
||||
} else {
|
||||
$logs = $this->site->logs()->latest()->simplePaginate(10);
|
||||
}
|
||||
|
||||
return view('livewire.server-logs.logs-list', compact('logs'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user