Maybe what you ask is very basic, but I'm getting involved in this: I have a list of Ejm products
What I need is to know if this product exists in my BDD and if I can enter it, they will tell me that is easy, but my way of inserting is the following, in order to create the code I keep the frequency + sequence.
That is why I consult the database to see if the code exists BY EJM 0021 to 0029, in this case there are 2 data that are 0021 and 0022, but if not, I need to be able to enter 0023, 0024, 0025 correlatively .
I have the following code where I ask when entered data exist belonging to the frequency and sequence
$nCod=Productos::where('frecuencia','=',$frecuencia)
->where('secuencia', '=', $secuencia)
->count();
if($nCod<10){
$buscar=Productos::where('frecuencia','=',$frecuencia)
->where('secuencia', '=', $secuencia)
->get();
}else{
echo "Error, no se puede ingresar.";
}
How can I do the cycle to know if the code exists, but enter it consecutively?