Skip to content

Commit d6aad79

Browse files
committed
Update README.md
1 parent 69b2db5 commit d6aad79

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Cadence provides a driver-based scheduling system for your Eloquent models using
2525
- [Usage](#usage)
2626
- [Adding Schedules](#adding-schedules)
2727
- [Timezones](#timezones)
28+
- [Disabling Schedules](#disabling-schedules)
2829
- [Running Due Schedules](#running-due-schedules)
2930
- [Listening for Triggered Schedules](#listening-for-triggered-schedules)
3031
- [Drivers](#drivers)
@@ -75,6 +76,14 @@ This creates a `schedules` table with the following columns:
7576
- `timezone` — optional timezone for the schedule
7677
- `next_run_at` — precomputed next occurrence for efficient querying
7778
- `last_run_at` — timestamp of the last run
79+
- `disabled_at` — timestamp indicating the schedule is disabled
80+
81+
If you're upgrading from an existing Cadence installation, publish and run the new migration before using the schedule enable / disable APIs:
82+
83+
```bash
84+
php artisan vendor:publish --provider="DirectoryTree\Cadence\CadenceServiceProvider"
85+
php artisan migrate
86+
```
7887

7988
## Setup
8089

@@ -146,6 +155,34 @@ $schedule->setTimezone('America/New_York');
146155
$report->addSchedule($schedule);
147156
```
148157

158+
### Disabling Schedules
159+
160+
Schedules may be disabled without deleting them:
161+
162+
```php
163+
$schedule->disable();
164+
```
165+
166+
Disabling a schedule sets `disabled_at` and clears `next_run_at`, so the schedule will not be picked up by the `schedules:run` command.
167+
168+
Enable the schedule again to compute its next occurrence from the current time:
169+
170+
```php
171+
$schedule->enable();
172+
```
173+
174+
You may also check or query schedule state:
175+
176+
```php
177+
use DirectoryTree\Cadence\Schedule;
178+
179+
$schedule->isEnabled();
180+
$schedule->isDisabled();
181+
182+
Schedule::enabled()->get();
183+
Schedule::disabled()->get();
184+
```
185+
149186
### Running Due Schedules
150187

151188
Register the `schedules:run` command in your application's scheduler to run every minute:

0 commit comments

Comments
 (0)