We have a checkout where customers can either create an account or checkout as a guest. If they register then the email and password columns in the database are both filled, whereas going as a guest only populates the email column and the password is left blank.
If a user tries to register a full account we need to make sure the e-mail address isn't already in use BY ANOTHER ACCOUNT - similarly, guest users need to be able to reuse the same address multiple times. So just using "unique:table,email" isn't quite enough - if registering, we also need to make sure the password has been populated.
How can I extend L5.1 validation to allow this? I've looked at the additional where clause section here: http://laravel.com/docs/5.1/validation#rule-unique but it looks like it has to be an equals clause. Is there a way to do "email is unique AND password is NOT empty"?
Taken an alternative approach and have created a 'guest' column in the database which I'm checking instead. This has solved my problem although I would welcome any replies pointing out whether my original plan is actually doable.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community