Forum: - TipTap WYSIWYG editor with full toolbar - @emoji-mart/react emoji picker (consistent with tweets) - @mention autocomplete with user search API - Fix PHP 8.4 parse errors in Blade templates - Fix thread data display (paginator items) - Align forum page widths to max-w-5xl Discover: - Extract shared _nav.blade.php partial - Add missing nav links to for-you page - Add Following link for authenticated users Feed/Posts: - Post model, controllers, policies, migrations - Feed page components (PostComposer, FeedCard, etc) - Post reactions, comments, saves, reports, sharing - Scheduled publishing support - Link preview controller Profile: - Profile page components (ProfileHero, ProfileTabs) - Profile API controller Uploads: - Upload wizard enhancements - Scheduled publish picker - Studio status bar and readiness checklist
56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Posts;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Post;
|
|
use App\Models\PostComment;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/**
|
|
* POST /api/posts/{post_id}/comments/{comment_id}/highlight
|
|
* DELETE /api/posts/{post_id}/comments/{comment_id}/highlight
|
|
*
|
|
* Only the post owner may highlight/un-highlight.
|
|
* Only 1 highlighted comment per post is allowed at a time.
|
|
*/
|
|
class PostCommentHighlightController extends Controller
|
|
{
|
|
public function highlight(Request $request, int $postId, int $commentId): JsonResponse
|
|
{
|
|
$post = Post::findOrFail($postId);
|
|
$comment = PostComment::where('post_id', $postId)->findOrFail($commentId);
|
|
|
|
if ($request->user()->id !== $post->user_id) {
|
|
abort(403, 'Only the post owner can highlight comments.');
|
|
}
|
|
|
|
DB::transaction(function () use ($post, $comment) {
|
|
// Remove any existing highlight on this post
|
|
PostComment::where('post_id', $post->id)
|
|
->where('is_highlighted', true)
|
|
->update(['is_highlighted' => false]);
|
|
|
|
$comment->update(['is_highlighted' => true]);
|
|
});
|
|
|
|
return response()->json(['message' => 'Comment highlighted.', 'comment_id' => $comment->id]);
|
|
}
|
|
|
|
public function unhighlight(Request $request, int $postId, int $commentId): JsonResponse
|
|
{
|
|
$post = Post::findOrFail($postId);
|
|
$comment = PostComment::where('post_id', $postId)->findOrFail($commentId);
|
|
|
|
if ($request->user()->id !== $post->user_id) {
|
|
abort(403, 'Only the post owner can remove comment highlights.');
|
|
}
|
|
|
|
$comment->update(['is_highlighted' => false]);
|
|
|
|
return response()->json(['message' => 'Highlight removed.', 'comment_id' => $comment->id]);
|
|
}
|
|
}
|