Ok, so this is my code.
What it does is check some worker's fields to find posible duplicates (I know this fields should be unique, but I can't do so much about that). So for instance if the field $credential_no
is set, it checks in DB, but if it's null, it doesn't because I don't want all the records that has null in that field.
The thing here, is that I need to check if at least some of that inputs ($credential_no || $ssn || $passport_no || $birthdate
) are defined because if not, the query will returns all the workers, cause are none where
condition, and I want results only if there's a match.
Also, by trying, I realice that I can use where
and orWhere
indistinctly, am I wrong? because if not I must use something like this:
My question is how can I make this thing better, how can I reduce this messy code, or there is no way in laravel to do this kind of thing?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire