<?php

namespace App\Http\Requests\Portal;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'category_id' => 'required|exists:categories,id',
            'name' => 'required|string|max:255',
            'slug' => 'required|string|max:255',
            'description' => 'nullable|string',
            'price' => 'required|numeric|min:0',
            'dine_in_price' => 'nullable|numeric|min:0',
            'delivery_price' => 'nullable|numeric|min:0',
            'takeaway_price' => 'nullable|numeric|min:0',
            'gst_percentage' => 'required|numeric|min:0|max:100',
            'tax_inclusive' => 'boolean',
            'available_dine_in' => 'boolean',
            'available_delivery' => 'boolean',
            'available_takeaway' => 'boolean',
            'photo' => 'nullable|image|max:2048',
            'is_veg' => 'boolean',
            'status' => 'required|in:available,out_of_stock',
            'is_active' => 'boolean',
            'sort_order' => 'integer',

            // Variants
            'variants' => 'nullable|array',
            'variants.*.name' => 'required|string|max:255',
            'variants.*.dine_in_price' => 'required|numeric|min:0',
            'variants.*.delivery_price' => 'required|numeric|min:0',
            'variants.*.takeaway_price' => 'required|numeric|min:0',
        ];
    }
}
