2026-01-22 23:38:00 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Livewire;
|
|
|
|
|
|
|
|
|
|
use App\Models\Article;
|
|
|
|
|
use App\Models\Setting;
|
|
|
|
|
use App\Jobs\ArticleDiscoveryJob;
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
use Livewire\WithPagination;
|
|
|
|
|
|
|
|
|
|
class Articles extends Component
|
|
|
|
|
{
|
|
|
|
|
use WithPagination;
|
|
|
|
|
|
|
|
|
|
public bool $isRefreshing = false;
|
|
|
|
|
|
|
|
|
|
public function approve(int $articleId): void
|
|
|
|
|
{
|
|
|
|
|
$article = Article::findOrFail($articleId);
|
|
|
|
|
$article->approve();
|
|
|
|
|
|
|
|
|
|
$this->dispatch('article-updated');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function reject(int $articleId): void
|
|
|
|
|
{
|
|
|
|
|
$article = Article::findOrFail($articleId);
|
|
|
|
|
$article->reject();
|
|
|
|
|
|
|
|
|
|
$this->dispatch('article-updated');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function refresh(): void
|
|
|
|
|
{
|
|
|
|
|
$this->isRefreshing = true;
|
|
|
|
|
|
|
|
|
|
ArticleDiscoveryJob::dispatch();
|
|
|
|
|
|
2026-03-07 17:22:05 +01:00
|
|
|
$this->dispatch('refresh-started');
|
2026-01-22 23:38:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
|
{
|
|
|
|
|
$articles = Article::with(['feed', 'articlePublication'])
|
|
|
|
|
->orderBy('created_at', 'desc')
|
|
|
|
|
->paginate(15);
|
|
|
|
|
|
|
|
|
|
$approvalsEnabled = Setting::isPublishingApprovalsEnabled();
|
|
|
|
|
|
|
|
|
|
return view('livewire.articles', [
|
|
|
|
|
'articles' => $articles,
|
|
|
|
|
'approvalsEnabled' => $approvalsEnabled,
|
|
|
|
|
])->layout('layouts.app');
|
|
|
|
|
}
|
|
|
|
|
}
|