<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Encryption\DecryptException;
use App\Rules\ExistRule;
use App\Rules\UpdateUniqueRule;
use Auth;
use EF;

class CallCenterRequest 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('callcommit'))
         {
         return $this->storeCall();
         }
        elseif($current_path === url('callupdate'))
         {
             return $this->updateCall();
         }

 }

 public function storeCall()
 {

    try
    {
       return [

        'name'              =>  'required|min:3|max:50',
        'cnic'              =>  'nullable|max:15',   
        'contact'           =>  'required|min:0|max:60',
        'interest'          =>  'nullable|min:0|max:1000',


    ];

}
catch (DecryptException $e) 
{

}

}
public function updateCall()
    {
       
        try
        {
             return [

            'name'         =>  'required|min:3|max:50',
            
            'cnic'              =>  'nullable|max:15',
            'contact'           =>  'required|min:0|max:60',
           
            'interest'          =>  'nullable||min:0|max:1000',
            
            ];

        }
        catch (DecryptException $e) 
        {
            
        }
       
    }
}
