<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreReviewRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'post_id' => 'required|exists:posts,id',
            'reviewee_id' => 'required|exists:users,id|different:' . $this->user()->id,
            'rating' => 'required|integer|min:1|max:5',
            'comment' => 'nullable|string|max:500',
        ];
    }

    public function messages(): array
    {
        return [
            'post_id.required' => 'Post wajib dipilih',
            'reviewee_id.required' => 'Penerima review wajib dipilih',
            'reviewee_id.different' => 'Kamu tidak bisa mereview diri sendiri',
            'rating.required' => 'Rating wajib diisi',
            'rating.min' => 'Rating minimal 1',
            'rating.max' => 'Rating maksimal 5',
        ];
    }
}
