<?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 BankRequest 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('bankcommit')) 
       {
           return $this->storeBank();
       }
       elseif ($current_path === url('bankupdate')) 
       {
           return $this->updateBank();
       }
    }

 public function storeBank()
 {
    try 
    {
            return[
                'bank_name'     =>  'required|min:3|max:50',
                'location'      =>  'required|min:3|max:80',
                'branch_code'   =>  'required|min:0|max:50',
                'title'         =>  'required|min:0|max:50',
                'account_no'   =>  'required|min:0|max:50',
            ];
    } 
    catch (Exception $e) 
    {

    }
 }

public function updateBank()
    {
       
        try
        {
             return [

                'bank_name'     =>  'required|min:3|max:50',
                'location'      =>  'required|min:3|max:80',
                'branch_code'   =>  'required|min:0|max:50',
                'title'         =>  'required|min:0|max:50',
                'account_no'   =>  'required|min:0|max:50',

            ];

        }
        catch (DecryptException $e) 
        {
            
        }
       
    }
}
