This commit is contained in:
Saeed Vaziry
2023-07-02 12:47:50 +02:00
commit 5c72f12490
825 changed files with 41659 additions and 0 deletions

View 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'));
}
}