dmag's avatar
Level 6

Queue: delay dispatching throws error

I'm trying to delay the dispatching of the job:

dispatch(new App\Jobs\ProcessOrder($orderData))->delay(10);

but get the following error:

Call to a member function delay() on integer

0 likes
4 replies
ahuggins's avatar

I think this is a limitation of the dispatch() helper function. That function, returns a new PendingDispatch object, but the constructor of the PendingDispatch class does not return the object, so I don't think you will be able to chain method calls on it.

You might be able to do ProcessOrder::dispatch($orderData)->delay(10) instead, or something along those lines.

1 like
ahuggins's avatar

actually, it should be ok, not sure why it is not working for you

ahuggins's avatar

What version of Laravel are you on?

Or what does the ProcessOrder job look like?

Please or to participate in this conversation.