<?php

namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class ReceivedCommentsController extends Controller
{
    public function index(Request $request)
    {
        $user = $request->user();
        if (! $user) {
            return redirect()->route('login');
        }

        try {
            $comments = app(\App\Services\LegacyService::class)->receivedComments($user->id);
        } catch (\Throwable $e) {
            $comments = collect();
        }

        return view('user.received-comments', [
            'comments' => $comments,
        ]);
    }
}
