PhyrePanel-mirror/web/app/Livewire/HostingSubscriptionBackupLog.php

46 lines
1.2 KiB
PHP
Raw Normal View History

2024-05-09 11:50:58 +00:00
<?php
namespace App\Livewire;
use Livewire\Component;
class HostingSubscriptionBackupLog extends Component
{
public $hostingSubscriptionBackupId;
public $backupLog;
2024-05-10 14:13:25 +00:00
public $backupLogFile = '';
2024-05-09 11:50:58 +00:00
public function pullBackupLog()
{
2024-05-10 14:13:25 +00:00
if ($this->backupLogFile) {
if (file_exists($this->backupLogFile)) {
$backupLogContent = shell_exec('tail -n 1000 ' . $this->backupLogFile);
2024-05-09 11:50:58 +00:00
// Get last 1000 lines of the log
$backupLogContent = substr($backupLogContent, -5000, 5000);
$backupLogContent = str_replace("\n", "<br>", $backupLogContent);
$this->backupLog = $backupLogContent;
}
}
}
2024-05-10 14:13:25 +00:00
2024-05-09 11:50:58 +00:00
public function mount($hostingSubscriptionBackupId)
{
$this->hostingSubscriptionBackupId = $hostingSubscriptionBackupId;
2024-05-10 14:13:25 +00:00
$findHsb = \App\Models\HostingSubscriptionBackup::where('id', $this->hostingSubscriptionBackupId)->first();
if ($findHsb) {
$this->backupLogFile = $findHsb->path . '/backup.log';
$this->pullBackupLog();
}
2024-05-09 11:50:58 +00:00
}
2024-05-09 12:44:00 +00:00
public function render()
2024-05-09 11:50:58 +00:00
{
return view('livewire.hosting-subscription-backup-log');
}
}