<?php

namespace App\Http\Controllers\Dashboard;

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

class FeedbackController extends Controller
{
    /**
     * Display all feedbacks
     */
    public function index()
    {
        $feedbacks = Feedback::orderBy('created_at', 'desc')->paginate(20);
        $totalFeedbacks = Feedback::count();
        
        return view('dashboard.feedback.index', compact('feedbacks', 'totalFeedbacks'));
    }

    /**
     * Display a specific feedback
     */
    public function show($id)
    {
        $feedback = Feedback::findOrFail($id);
        return view('dashboard.feedback.show', compact('feedback'));
    }

    /**
     * Delete a feedback
     */
    public function destroy($id)
    {
        $feedback = Feedback::findOrFail($id);
        $feedback->delete();
        
        return redirect()->route('feedback.index')
            ->with('success', 'Feedback deleted successfully');
    }
}

