<?php

namespace App\Http\Controllers\Api\V1\Entrepreneur\Requests;

use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;

class VendorProductStoreRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            // essentials...
            'name' => ['required', 'string', 'max:255'],
            'description' => ['nullable', 'string', 'max:255'],
            'files' => ['nullable'],

            // prices...
            'cost_amount' => ['required', 'numeric'],
            'old_price_amount' => ['nullable', 'numeric', 'gt:cost_amount'],

            // relationships...
            // 'integer', 'exists:brands,id'
            'brand_id' => ['nullable'],
            'category_ids' => ['required', 'array'],
            'collection_ids' => ['nullable', 'array'],

            // inventories...
            'stock' => ['required', 'integer', 'min:1'],
            'sku' => ['nullable', 'string', 'max:255'],
            'barcode' => ['nullable', 'string', 'max:255', 'unique:products,barcode'],
        ];
    }
}
