Skip to content

[11.x] Add pingOnSuccessIf & pingOnFailureIf to Schedule handling#53795

Merged
taylorotwell merged 3 commits intolaravel:11.xfrom
lucacastelnuovo:patch-1
Dec 8, 2024
Merged

[11.x] Add pingOnSuccessIf & pingOnFailureIf to Schedule handling#53795
taylorotwell merged 3 commits intolaravel:11.xfrom
lucacastelnuovo:patch-1

Conversation

@lucacastelnuovo
Copy link
Copy Markdown
Contributor

@lucacastelnuovo lucacastelnuovo commented Dec 8, 2024

Currently pingBeforeIf() exists. Which can be used like this:

Schedule::command('backup:run')->hourly()
    ->pingBefore((bool) config('services.ohdear.tasks.backup:run', false), config('services.ohdear.tasks.backup:run') . '/starting')

This PR proposes adding the same functionality to the pingOnSuccess and the pingOnFailure methods. (https://laravel.com/docs/11.x/scheduling#pinging-urls)

This makes it possible to write the following code:

$pingBackupRun = (bool) config('services.ohdear.tasks.backup:run', false);
$pingBackupRunUrl = config('services.ohdear.tasks.backup:run');

Schedule::command('backup:run')->hourly()
    ->pingBeforeIf($pingBackupRun, $pingBackupRunUrl . '/starting')
    ->pingOnSuccessIf($pingBackupRun, $pingBackupRunUrl . '/finished')
    ->pingOnFailureIf($pingBackupRun, $pingBackupRunUrl . '/failed');

This is my first PR to the laravel/framework repo. Let me know if I did something wrong :)

@zakariaarrid
Copy link
Copy Markdown

Hi @lucacastelnuovo !
can you check updated doc ?

@lucacastelnuovo
Copy link
Copy Markdown
Contributor Author

Hi @lucacastelnuovo !

can you check updated doc ?

I'm sorry, I don't understand the question. Could you clarify?

@lucacastelnuovo lucacastelnuovo deleted the patch-1 branch December 8, 2024 16:36
@zakariaarrid
Copy link
Copy Markdown

Hi @lucacastelnuovo !
can you check updated doc ?

I'm sorry, I don't understand the question. Could you clarify?

I have submitted a pull request for the Laravel documentation regarding your new functions. Kindly review it here.

@lucacastelnuovo
Copy link
Copy Markdown
Contributor Author

I have submitted a pull request for the Laravel documentation regarding your new functions. Kindly review it here.

Looks great, thank you. I forgot to do it myself.

browner12 pushed a commit to browner12/framework that referenced this pull request Dec 10, 2024
…ravel#53795)

* Add pingOnSuccessIf & pingOnFailureIf

* [fix]: style error

* Update Event.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
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.

3 participants