<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use App\Rules\ExistRule;
use EF;
class TransferRequest 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('transfercommit'))
        {
           return $this->storeTransfer();
        }
        elseif($current_path === url('transferupdate'))
        {
           return $this->updateTransfer();
        }

    }


     public function storeTransfer()
    {
        $validate = $this->input();
        $label_list = EF::getWhiteLabel();
        return [
       
             'user_id'                            =>  ['required', new ExistRule('users','id')],
             'booking_id'                         =>  ['required', new ExistRule('bookings','id')],
             'customer_cnic'                      =>  'required|min:0|max:25',
              $label_list['remarks']              =>  'nullable|max:500',
              $label_list['transfer_fee']         =>  'nullable|integer',
              $label_list['transfer_date']        =>  'date|date_format:Y-m-d|after:1970-01-01',
          
        ];
    }

    public function updateTransfer()
    {
        $validate = $this->input();
         $label_list = EF::getWhiteLabel();
        return [
           
              $label_list['transfer_fee']         =>  'nullable|integer',
              $label_list['transfer_date']        =>  'date|date_format:Y-m-d|after:1970-01-01',
          
          
        ];
    }
}
