<?php

namespace App\Http\Requests\Order;

use Illuminate\Foundation\Http\FormRequest;

class StoreOrderRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return auth()->check();
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'id'                => 'nullable|exists:orders,id',
            'name'              => 'required|string',
            'user_id'           => 'required|exists:users,id',
            'district_id'       => 'required|exists:districts,id',
            'area_id'           => 'required|exists:areas,id',
            'object_address'    => 'required|string|min:5',
            'object_type_id'    => 'required|exists:object_types,id',
            'comment'           => 'nullable|string',
            'installation_date' => 'nullable|date',
            'ready_date'        => 'nullable|date',
            'brigadier_id'      => 'nullable|exists:users,id',
            'tg_group_name'     => 'nullable|string',
            'tg_group_link'     => 'nullable|string',
            'products'          => 'nullable|array',
            'quantity'          => 'nullable|array',
            'products_sku'      => 'nullable|array',
            'order_status_id'   => 'nullable|exists:order_statuses,id',
        ];
    }
}
