79206069

Date: 2024-11-20 06:45:49
Score: 0.5
Natty:
Report link

Once your 'deleted' event gets triggered the model is already gone. Hence the model not found error because you are deleting the model and then passing it into the job constructor.

You can solve this by passing the id (assuming the id is the same for all tenants) of your model and retrieving the model in the job itself.

Documentation:

When injecting an Eloquent model into a job, the model is automatically serialized before being placed on the queue and re-retrieved from the database when the job is processed. However, if the model has been deleted while the job was waiting to be processed by a worker, your job may fail with a ModelNotFoundException.

https://laravel.com/docs/11.x/queues#ignoring-missing-models

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: kopz