As I pointed out in a stackoverflow question, the dispatch() helper now returns a PendingDispatch object, instead of the id of the job.
In fact, trying to access the result of the dispatch() helper returns:
Object of class Illuminate\Foundation\Bus\PendingDispatch could not be converted to string
What if I want to retrieve the job id of the newly created job in the queue, as I did before?
I didn't find anything in the documentation or in the upgrade guide.
$job = (new JobClass());
$jobId = dispatch($job);
echo $jobId; // Generates exception
You can use this to have the same output as in 5.4:
app(\Illuminate\Contracts\Bus\Dispatcher::class)->dispatch($job)
Thank you, this solves the problem. Might be the case to add this to the 5.4 -> 5.5 upgrade guide docs?
The DispatchesJob trait makes this easier. It's applied to controllers by default but it can be added to other classes too.