<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class EstimateAcceptRequest extends FormRequest
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'first_name' => 'required',
            'last_name' => 'required',
            'email' => 'required|email:rfc,strict',
            'item_responses' => 'nullable|array',
            'item_responses.*' => 'nullable|in:yes,no',
        ];

        if(request('signature_type') == 'upload'){
            $rules['image'] = 'required';
        }
        else {
            $rules['signature'] = 'required';
        }

        return $rules;
    }

}
