2025-06-29 17:24:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use App\Models\Article;
|
2025-07-10 14:57:10 +02:00
|
|
|
use App\Models\Setting;
|
2025-06-29 17:24:35 +02:00
|
|
|
use Illuminate\Contracts\View\View;
|
2025-07-10 14:57:10 +02:00
|
|
|
use Illuminate\Http\RedirectResponse;
|
2025-06-29 17:24:35 +02:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class ArticlesController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function __invoke(Request $request): View
|
|
|
|
|
{
|
2025-07-03 21:34:39 +02:00
|
|
|
$articles = Article::with('articlePublication')
|
|
|
|
|
->orderBy('created_at', 'desc')
|
|
|
|
|
->paginate(15);
|
2025-06-29 17:24:35 +02:00
|
|
|
|
2025-07-10 14:57:10 +02:00
|
|
|
$publishingApprovalsEnabled = Setting::isPublishingApprovalsEnabled();
|
|
|
|
|
|
|
|
|
|
return view('pages.articles.index', compact('articles', 'publishingApprovalsEnabled'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function approve(Article $article): RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
$article->approve('manual');
|
|
|
|
|
|
|
|
|
|
return redirect()->back()->with('success', 'Article approved and queued for publishing.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function reject(Article $article): RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
$article->reject('manual');
|
|
|
|
|
|
|
|
|
|
return redirect()->back()->with('success', 'Article rejected.');
|
2025-06-29 17:24:35 +02:00
|
|
|
}
|
|
|
|
|
}
|