I am starting a new project and need to do the following:
Visitor lands at a url with a form to fill in
They enter a 6 digit code they have been provided into the form field
They submit the form, and Kirby checks if the number is in a stored set of numbers
If it is, Kirby removes that number from the set (and does some other stuff with user generation, permissions etc).
I am fine with everything but the best format for storing the set of numbers to check against. I have done something like this before where I checked against a tags field, so comma separated values, but in this case the number set is going to be 3,000 entries long, so that might not be the best option?
Should I be storing them in a csv? json? Or is in a standard Kirby content file ok even with the large number of values?
If anyone has any thoughts as to best practice here that would be super.
storing them in a single file or page content should be fine both in regard of performance and concurrency (as you remove unique values and do not do stuff like incrementing).
unless visitors can compete for values (be shown the same in the form at the same time) you do not need any special optimizations imho.
I am giving it a go with adding the unique code values in a comma separated list in the content file as codes. I am checking for the existence of a number like so:
$codes = $page->codes()->split();
if(A::has($codes,'123456')):
// Do the thing
endif;
I am not sure of the best way to remove the code if it is found in the array. I have used remove before for collections, but that doesn’t work as $codes is an array. Is there anything you would suggest?