<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use App\Rules\ExistRule;
use EF;

class SupportRequest 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('supportcommit'))
        {
           return $this->storeComplaint();
        }
        elseif($current_path === url('supportupdate'))
        {
           return $this->updateComplaint();
        }
        elseif($current_path === url('supportcomment'))
        {
           return $this->storeComments();
        }

    
    }

    public function storeComplaint(){
                                      
    try
        {  
          $priority  = implode(',',EF::getPriorityList());
            return [

           'employee_name'    =>  'required',
           'title'            =>  'required',
           'priority'         =>  'required|in:'.$priority,
           'description'      =>  'required',
                             
            ];


        

        }
        catch (\Exception $e) 
        {
            
        }
   }

    public function updateComplaint(){
    
                                  
    try
        {  
          $priority  = implode(',',EF::getPriorityList());
            return [

           'employee_name'    =>  'required',
           'title'            =>  'required',
           'priority'         =>  'required|in:'.$priority,
           'description'      =>  'required',
           'id'               =>  'required'
                             
            ];


        

        }
        catch (\Exception $e) 
        {
            
        }
   }

   public function storeComments(){
    
                                  
    try
        {  
            return [

           'client_comment'    =>  'required',
           
                             
            ];


        

        }
        catch (\Exception $e) 
        {
            
        }
   }



}
