1

I have two tables one is banking and another one is a type (banking types). banking table has many types and types that belong to banking. once I create the account, I need to validate banking type_id and banking_id in the types table (i need to validate banking id and type id at the same time for avoiding user enter the wrong combination of banking and type). How can I do that with Laravel validation? both columns required and need to implement above scenario.

Types table.

enter image description here

current validation.

'type_id' => 'required|exists:types,id',
'banking_id' => 'required|exists:bankings,id',
Nishantha Kumara
  • 345
  • 2
  • 16

1 Answers1

1

You can create youre own validation rule if you want.

php artisan make:rule YourValidation

then put on the passes your condition on validation

 public function passes($attribute, $value)
    {
        //
    }

then enter you validation error message on

  public function message()
    {
        return 'The validation error message.';
    }
kamote ulalo
  • 162
  • 5