I need to update the position value but the auto-increment ID is immutable.
At the end of the day, I want a sortable list of records, ordered by position.
One idea is to let php sleep for 500ms after upload.
But this feels really awful.
@alexanderhempel For your Dropzone settings, you can set it so that it does not try to upload everything at once and does it sequentially.
Dropzone.options.myAwesomeDropzone = {
// This uploads 1 at a time and so it waits till
// the previous one is done before
// starting the next upload
parallelUploads: 1
};
This should make it so that your count() method works now.
There's also probably a way to hook into the upload and pass in the current position of the upload, but not sure. You should look at the docs for that. :)
@alexanderhempel "When i sort by ID, there is no way to update the ID, right?" ... why do you want to? What is the position for?
@thomaskim I'd be a bit wary of relying on that to fix the process - one little slip when adding a dropzone object (or the option changes name sometime) and the app would break again :-) And possibly if multiple people are uploading at the same time it'll trigger the same problem - maybe ;-)
Are you creating multiple instances of SplashImage but not saving them until after you set the position attribute? That would result in the value of SplashImage::count() being off. Can you post the relevant methods from your model and controller?
@thepsion5
I return the instance to another method and save it there.
The "problem" was that the application is able to process 2 post requests at the same time.
I could fix that, by set the dropzone option "parallelUploads" to 1.