<?php

namespace App\Http\Requests\Admin\Manage;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'description' => ['nullable', 'string', 'max:100'],
            'product_name' => ['required', 'string', 'max:255'],
            'sample' => ['required', 'integer', 'min:0'],
            'original_outside_sample' => ['required', 'integer', 'min:0'],
            'cutting_result' => ['required', 'integer', 'min:0'],
            'materials' => ['required', 'array', 'min:1'],
            'materials.*.raw_material_price_id' => ['required', 'integer', 'exists:raw_material_prices,id'],
            'materials.*.material_usage' => ['required', 'integer', 'min:0'],
            'materials.*.material_result' => ['required', 'integer', 'min:0'],
            'materials.*.combination_index' => ['nullable', 'integer', 'min:0'],
            'combinations' => ['nullable', 'array'],
            'combinations.*.material_result' => ['nullable', 'integer', 'min:0'],
            'photo_key' => ['nullable', 'string', 'max:500'],
        ];
    }

    public function attributes(): array
    {
        return [
            'description' => 'Keterangan',
            'product_name' => 'Nama Produk',
            'sample' => 'Sample',
            'original_outside_sample' => 'Diluar Sample',
            'cutting_result' => 'Hasil',
            'materials' => 'Bahan Baku',
            'materials.*.raw_material_price_id' => 'Varian Bahan Baku',
            'materials.*.material_usage' => 'Pemakaian',
            'materials.*.material_result' => 'Hasil Material',
            'materials.*.combination_index' => 'Indeks Kombinasi',
            'combinations' => 'Kombinasi',
            'combinations.*.material_result' => 'Hasil Kombinasi',
            'photo_key' => 'Foto',
        ];
    }
}
