F
Filament14mo ago
FDG

Mass create resources by dispatching jobs

Hi, I have a resource where data in a textarea can be submitted each line should be a new entry. I'm using the handleRecordCreation to loop through the lines and then dispatch them to a job in chunks (sometimes the entry can be 1million + lines) Currently it's all working fine, but I had to work around the following in the handleRecordCreation function: The function needs to return a model, only way I could get it to work is return a new instance of a model with return new Model(); now I noticed this conflicts with some code in the job since the handleRecordCreation is being overwritten to return a new instance of Model everytime it's called. I solved this by manually retrieving the model each time it is created in the jobs loop. Is there a way I can fix this with that I don't know of yet or should I just stick to returning new Model();
2 Replies
FDG
FDGOP14mo ago
Bypass I mentioned:
//Need to find the model by $Id because filament is overwriting it to id 0 causing errors

$model = Model::find($id);
//Need to find the model by $Id because filament is overwriting it to id 0 causing errors

$model = Model::find($id);
we are attaching a relationship here, before I started using this bypass the model would just get attached to the newly "created "model instance (id 0) pls
Dennis Koch
Dennis Koch13mo ago
I would just overwrite the whole submit() method of the page instead. Or use an action on the list page. You could also have a look at. #import-inline-form-paste
Want results from more Discord servers?
Add your server