First Commit

This commit is contained in:
Esteban
2026-07-03 16:27:34 +02:00
commit 7a7440daab
8955 changed files with 1117958 additions and 0 deletions
@@ -0,0 +1,64 @@
<?php
namespace App\Http\Controllers;
use App\Models\Article;
use App\Services\ArticleReaderService;
use App\Support\MarkdownRenderer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;
class ArticleController extends Controller
{
public function show(Article $article, ArticleReaderService $reader): View
{
$this->authorize('view', $article);
if (! $article->is_read) {
$article->update(['is_read' => true]);
}
if ($article->full_content_markdown === null && $article->full_content_error === null) {
$reader->fetchFullContent($article);
}
return view('articles.show', [
'article' => $article,
'contentHtml' => MarkdownRenderer::toHtml($article->full_content_markdown),
]);
}
public function retry(Article $article, ArticleReaderService $reader): RedirectResponse
{
$this->authorize('update', $article);
$article->full_content_error = null;
$article->save();
$reader->fetchFullContent($article);
return redirect()->route('articles.show', $article);
}
public function markRead(Article $article): JsonResponse|RedirectResponse
{
$this->authorize('update', $article);
$article->update(['is_read' => true]);
return request()->wantsJson()
? response()->json(['is_read' => true])
: back();
}
public function toggleFavorite(Article $article): JsonResponse|RedirectResponse
{
$this->authorize('update', $article);
$article->update(['is_favorite' => ! $article->is_favorite]);
return request()->wantsJson()
? response()->json(['is_favorite' => $article->is_favorite])
: back();
}
}