<?php

namespace App\Http\Requests;

use App\Models\Asset;
use Gate;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Response;

class UpdateAssetRequest extends FormRequest
{
    public function authorize()
    {
        return Gate::allows('asset_edit');
    }

    public function rules()
    {
        return [
            'client_id' => [
                'required',
                'integer',
            ],
            'locations.*' => [
                'integer',
            ],
            'locations' => [
                'array',
            ],
            'commissioning' => [
                'string',
                'required',
            ],
            'air_compressor_serial_no' => [
                'string',
                'nullable',
            ],
            'air_compressor_part_no' => [
                'string',
                'nullable',
            ],
            'airdryer_serial_no' => [
                'string',
                'nullable',
            ],
            'air_dryer_part_no' => [
                'string',
                'nullable',
            ],
            'filter_serial_no' => [
                'string',
                'nullable',
            ],
            'filter_part_no' => [
                'string',
                'nullable',
            ],
            'eco_drain_serial_no' => [
                'string',
                'nullable',
            ],
            'eco_drain_part_no' => [
                'string',
                'nullable',
            ],
            'air_receiver_serial_no' => [
                'string',
                'nullable',
            ],
            'air_reciever_part_no' => [
                'string',
                'nullable',
            ],
            'commisioned_date' => [
                'date_format:' . config('panel.date_format'),
                'nullable',
            ],
            'warranty_start_date' => [
                'date_format:' . config('panel.date_format'),
                'nullable',
            ],
            'warranty_end_date' => [
                'date_format:' . config('panel.date_format'),
                'nullable',
            ],
            'start_of_work' => [
                'string',
                'nullable',
            ],
            'end_of_work' => [
                'string',
                'nullable',
            ],
            'travelling_time' => [
                'string',
                'nullable',
            ],
            'travelling_k_m' => [
                'string',
                'nullable',
            ],
            'asset_photos' => [
                'array',
            ],
        ];
    }
}
