<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class DeveloperOverrideRequest extends FormRequest
{
    public function authorize(): bool
    {
        return auth()->check() && auth()->user()->isDeveloper();
    }

    public function rules(): array
    {
        return [
            'reason' => ['required', 'string', 'min:10', 'max:1000'],
            'developer_password' => ['required', 'string', 'min:6'],

            'customer_id' => ['nullable', 'exists:customers,id'],
            'payment_status' => ['nullable', 'in:unpaid,partial,paid'],
            'production_status' => ['nullable', 'in:pending,proses_cetak,finishing,selesai'],
            'pickup_status' => ['nullable', 'in:not_picked_up,picked_up'],
            'is_credit' => ['nullable', 'boolean'],
            'notes' => ['nullable', 'string', 'max:1000'],
            'cashier_id' => ['nullable', 'exists:users,id'],
            'operator_id' => ['nullable', 'exists:users,id'],
            'designer_id' => ['nullable', 'exists:users,id'],

            'amount' => ['nullable', 'numeric', 'min:0'],
            'payment_method' => ['nullable', 'in:cash,transfer,ewallet'],
            'payment_account_id' => ['nullable', 'exists:payment_accounts,id'],
        ];
    }
}
