<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Review;
use App\Models\Event;

class ReviewController extends Controller
{
    public function store(Request $request, Event $event)
    {
        $request->validate([
            'customer_name' => 'required|string|max:255',
            'rating' => 'required|integer|min:1|max:5',
            'review' => 'required|string|min:10',
        ]);

        Review::create([
            'event_id' => $event->id,
            'customer_name' => $request->customer_name,
            'rating' => $request->rating,
            'review' => $request->review,
        ]);

        return redirect()->route('events.show', $event->id)
            ->with('success', 'Review berhasil dikirim! Terima kasih atas feedback Anda.');
    }
}

