2026-01-22 23:38:00 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Livewire;
|
|
|
|
|
|
|
|
|
|
use App\Models\Setting;
|
2026-03-18 20:01:25 +01:00
|
|
|
use Illuminate\Contracts\View\View;
|
2026-01-22 23:38:00 +01:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class Settings extends Component
|
|
|
|
|
{
|
|
|
|
|
public bool $articleProcessingEnabled = true;
|
2026-03-08 14:18:28 +01:00
|
|
|
|
2026-01-22 23:38:00 +01:00
|
|
|
public bool $publishingApprovalsEnabled = false;
|
2026-03-08 14:18:28 +01:00
|
|
|
|
2026-03-08 11:25:50 +01:00
|
|
|
public int $articlePublishingInterval = 5;
|
2026-01-22 23:38:00 +01:00
|
|
|
|
2026-03-09 17:32:55 +01:00
|
|
|
public int $feedStalenessThreshold = 48;
|
|
|
|
|
|
2026-01-22 23:38:00 +01:00
|
|
|
public ?string $successMessage = null;
|
2026-03-08 14:18:28 +01:00
|
|
|
|
2026-01-22 23:38:00 +01:00
|
|
|
public ?string $errorMessage = null;
|
|
|
|
|
|
|
|
|
|
public function mount(): void
|
|
|
|
|
{
|
|
|
|
|
$this->articleProcessingEnabled = Setting::isArticleProcessingEnabled();
|
|
|
|
|
$this->publishingApprovalsEnabled = Setting::isPublishingApprovalsEnabled();
|
2026-03-08 11:25:50 +01:00
|
|
|
$this->articlePublishingInterval = Setting::getArticlePublishingInterval();
|
2026-03-09 17:32:55 +01:00
|
|
|
$this->feedStalenessThreshold = Setting::getFeedStalenessThreshold();
|
2026-01-22 23:38:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toggleArticleProcessing(): void
|
|
|
|
|
{
|
2026-03-08 14:18:28 +01:00
|
|
|
$this->articleProcessingEnabled = ! $this->articleProcessingEnabled;
|
2026-01-22 23:38:00 +01:00
|
|
|
Setting::setArticleProcessingEnabled($this->articleProcessingEnabled);
|
|
|
|
|
$this->showSuccess();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function togglePublishingApprovals(): void
|
|
|
|
|
{
|
2026-03-08 14:18:28 +01:00
|
|
|
$this->publishingApprovalsEnabled = ! $this->publishingApprovalsEnabled;
|
2026-01-22 23:38:00 +01:00
|
|
|
Setting::setPublishingApprovalsEnabled($this->publishingApprovalsEnabled);
|
|
|
|
|
$this->showSuccess();
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-08 11:25:50 +01:00
|
|
|
public function updateArticlePublishingInterval(): void
|
|
|
|
|
{
|
|
|
|
|
$this->validate([
|
|
|
|
|
'articlePublishingInterval' => 'required|integer|min:0',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
Setting::setArticlePublishingInterval($this->articlePublishingInterval);
|
|
|
|
|
$this->showSuccess();
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-09 17:32:55 +01:00
|
|
|
public function updateFeedStalenessThreshold(): void
|
|
|
|
|
{
|
|
|
|
|
$this->validate([
|
|
|
|
|
'feedStalenessThreshold' => 'required|integer|min:0',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
Setting::setFeedStalenessThreshold($this->feedStalenessThreshold);
|
|
|
|
|
$this->showSuccess();
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-22 23:38:00 +01:00
|
|
|
protected function showSuccess(): void
|
|
|
|
|
{
|
|
|
|
|
$this->successMessage = 'Settings updated successfully!';
|
|
|
|
|
$this->errorMessage = null;
|
|
|
|
|
|
|
|
|
|
// Clear success message after 3 seconds
|
|
|
|
|
$this->dispatch('clear-message');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function clearMessages(): void
|
|
|
|
|
{
|
|
|
|
|
$this->successMessage = null;
|
|
|
|
|
$this->errorMessage = null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 20:01:25 +01:00
|
|
|
public function render(): View
|
2026-01-22 23:38:00 +01:00
|
|
|
{
|
|
|
|
|
return view('livewire.settings')->layout('layouts.app');
|
|
|
|
|
}
|
|
|
|
|
}
|