<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use App\Rules\ExistRule;
use EF;
class DocumentRequest 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()
    {
       
        EF::errorMessage('Required form validation.');
        
        $current_path = url()->current();

        if($current_path === url('booking_documentcommit'))
        {
           return $this->storeBookingDocument();
        }
       
        
    }

     public function storeBookingDocument()
    {
      
        return [

             'user_id'                       =>  ['required', new ExistRule('users','id')],
             'booking_id'                    =>  ['required', new ExistRule('bookings','id')],
             'document_title'                =>  'required|min:1|max:100',
             'document_description'          =>  'required|min:1|max:500',
             'document'                      =>  'required|mimes:jpeg,png,jpg,pdf|max:350',
          
        ];
    }
}
