<?php

namespace App\Http\Requests\InventoryRequests;

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

class GinRequest 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('Form Validation.');

        $current_path = url()->current();


        if($current_path === url('gin_commit'))
        {
           return $this->getValidationList();
        }
        if($current_path === url('gin_commit_service'))
        {
           return $this->getValidationList2();
        }

    }
     public function getValidationList()
    {
        $validation = [
           'product_id'                 =>  ['required', new ExistRule('items','id')],
           'quantity'                 =>  'required|min:1',
           'receiver_id'                 =>  ['required'],
           'remarks'                 =>  'required',

        ];
        return $validation;
    }

    public function getValidationList2()
    {
       $validation = [
          'service_id'                 =>  ['required', new ExistRule('items','id')],
          'receiver_id'                 =>  ['required'],
          'remarks'                 =>  'required',

       ];
       return $validation;
    }


}
