<?php

namespace Gisplus\Package\Crm\Requests;

use Illuminate\Foundation\Http\FormRequest;
use EF;

class VisitRequest 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()
    {
        
            $current_path = url()->current();

            if ($current_path === url('visitcommit')) {
    
                $validation = $this->getValidationList();
                return $validation;
            }

     
    }

    public function getValidationList()
    {
        $type_list = implode(',', EF::getVisitType());
        $validation = [

            'date'              =>  'required|date|date_format:Y-m-d',
            'description'       =>  'nullable|min:0|max:255',
            'added_by'          =>  'nullable',
            'type'              =>  'In:'.$type_list,
          
        ];

        return $validation;
    }

}
