validate unique or equal

Solutions on MaxInterview for validate unique or equal by the best coders in the world

showing results for - "validate unique or equal"
Laura
14 Mar 2017
1//Use an if statement to validate some items conditionally:
2$request->validate([ //Always validated
3	'name' => ['string'],
4	'some_number' => ['numeric', 'integer']
5]);
6if ($request->email != $user->email) //Validated only if different from user's currently stored email
7	$request->validate([
8    	'email' => ['email', 'unique:users']
9    ]);