Skip to content

Conversation

@kenneth-saey
Copy link
Contributor

A quality of life improvement that allows the afterResponse option to be set conditionally, to simplify call site code.

A boolean $afterResponse parameter has been added to the PendingDispatch::afterResponse() method with a default value of true which ensures backwards compatibility.

This change can improve call site code by no longer requiring an if-test when the PendingDispatch should not always be executed after the response has been sent to the client.

Before:

if (env('APP_ENV') === 'local') {
    MyJob::dispatch($myData)
         ->afterResponse();
} else {
    MyJob::dispatch($myData);
}

After:

MyJob::dispatch($myData)
     ->afterResponse(env('APP_ENV') === 'local');

A quality of life improvement that allows the afterResponse option to be set conditionally, to simplify call site code.
@github-actions
Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@kenneth-saey kenneth-saey marked this pull request as ready for review December 12, 2025 09:06
@kenneth-saey kenneth-saey changed the title Make PendingDispatch::afterResponse conditional [12.x] Make PendingDispatch::afterResponse conditional Dec 12, 2025
@taylorotwell taylorotwell merged commit 9807448 into laravel:12.x Dec 12, 2025
72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants