You've already forked Atomcms-edit
4094f0fb14
HIGH: - Add missing import RadioSongRequestFormRequest (fixes crash on POST) - Add Purify XSS sanitization for article full_story - Fix duplicate radio API routes (/api/radio vs /api/radio/v2) - Add try-catch guards in InstallationController for missing records MEDIUM: - Fix N+1: eager load comments.user in ArticleController::show() - Fix GuestbookController authorization logic - Remove dead doSetup() method and duplicate route - Extract shared HasRadioDefaults trait (remove code duplication) - Use named routes in ForceStaffTwoFactorMiddleware - Fix WebsiteHelpCenterTicket::isOpen() (no permission leak) - Enable on WebsiteHelpCenterTicket (matches schema) - Replace WebsiteTeam::all()->pluck() with direct pluck() - Replace CatalogPage::all()->pluck() with direct pluck() - Replace WebsiteBadge::all() with direct pluck() - Add throttle middleware to guestbook store, logo-generator, radio embed LOW: - Remove unused imports - Remove dead /inertia-test route - Consolidate cache keys in RadioController
53 lines
1.6 KiB
PHP
Executable File
53 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Articles;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Articles\WebsiteArticle;
|
|
use App\Services\Articles\ArticleService;
|
|
use App\Services\Articles\ReactionService;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class ArticleController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly ArticleService $articlesService,
|
|
private readonly ReactionService $reactionService,
|
|
) {}
|
|
|
|
public function index(): View
|
|
{
|
|
$articles = $this->articlesService->getArticles(true);
|
|
|
|
return view('community.articles', [
|
|
'articles' => $articles,
|
|
]);
|
|
}
|
|
|
|
public function show(WebsiteArticle $article): View
|
|
{
|
|
$article->load(['user:id,username,look', 'comments.user:id,username,look']);
|
|
|
|
$reactions = $article->reactions()
|
|
->with('user:id,username')
|
|
->get();
|
|
|
|
return view('community.article', [
|
|
'article' => $article,
|
|
'otherArticles' => WebsiteArticle::whereKeyNot($article->id)->with('user:id,username,look')->latest('id')->take(15)->get(),
|
|
'myReactions' => Auth::check() ? $reactions->where('user_id', Auth::id())->pluck('reaction') : [],
|
|
'articleReactions' => $reactions->groupBy('reaction', true),
|
|
]);
|
|
}
|
|
|
|
public function toggleReaction(WebsiteArticle $article, Request $request): JsonResponse
|
|
{
|
|
$response = $this->reactionService->toggleReaction($article, Auth::user(), $request);
|
|
|
|
return response()->json($response);
|
|
}
|
|
}
|