<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'category_id' => 'sometimes|exists:categories,id',
            'title' => 'sometimes|string|max:255',
            'description' => 'sometimes|string',
            'price_type' => 'sometimes|in:fixed,negotiable,free_to_offer',
            'price_min' => 'nullable|integer|min:0',
            'price_max' => 'nullable|integer|min:0|gte:price_min',
            'price_label' => 'nullable|string|max:100',
            'location' => 'nullable|string|max:100',
            'is_remote' => 'boolean',
            'deadline' => 'nullable|date|after:now',
            'tags' => 'nullable|array|max:10',
            'tags.*' => 'string|max:50',
            'image' => 'nullable|image|mimes:jpg,jpeg,png,webp|max:100',
            'remove_image' => 'nullable|boolean',
        ];
    }
}
