<?php

namespace App\Http\Requests\Package;

use Illuminate\Foundation\Http\FormRequest;

class AddPackageRequest extends FormRequest
{
    public function authorize()
    {
        return true; // Adjust if you need role checks
    }

    public function rules(): array
    {
        return [
            'vendor_id' => ['required', 'string', 'exists:vendors,track_id'],
            'sub_category_id' => ['required', 'string', 'exists:vendor_sub_categories,track_id'],
            'name' => ['required', 'string', 'max:255'],
            'description' => ['required', 'string'],
            'images' => ['nullable', 'array'],
            'images.*' => ['nullable', 'string'],
            'price' => ['required', 'numeric', 'min:0'],
            'quantity' => ['required', 'integer', 'min:1'],
            'status' => ['nullable', 'integer', 'in:0,1'],
        ];
    }

    public function messages()
    {
        return [
            'vendor_id.exists' => 'Vendor does not exist.',
            'sub_category_id.exists' => 'Vendor Sub category does not exist.',
        ];
    }    
}
