Skip to content

Commit

Permalink
Include documentation for between and unlessBetween
Browse files Browse the repository at this point in the history
Add examples and some additional details for [this feature](laravel/framework#15216)
  • Loading branch information
JacobBennett authored Sep 2, 2016
1 parent 2e958e2 commit 3b86b79
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions scheduling.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ These methods may be combined with additional constraints to create even more fi
->weekdays()
->hourly()
->timezone('America/Chicago')
->when(function () {
return date('H') >= 8 && date('H') <= 17;
});
->between('8:00', '17:00');

Below is a list of the additional schedule constraints:

Expand All @@ -120,6 +118,7 @@ Method | Description
`->fridays();` | Limit the task to Friday
`->saturdays();` | Limit the task to Saturday
`->when(Closure);` | Limit the task based on a truth test
`->between($start, $end);` | Limit the task to run between start and end times

#### Truth Test Constraints

Expand All @@ -138,6 +137,17 @@ The `skip` method may be seen as the inverse of `when`. If the `skip` method ret
When using chained `when` methods, the scheduled command will only execute if all `when` conditions return `true`.

<a name="preventing-task-overlaps"></a>

#### Between Time Constraints

The `between` method may be used to limit the execution of a task based on the time of day.

$schedule->command('reminders:send')->hourly()->between('7:00', '22:00');

Similarly, the `unlessBetween` method can be used to exclude the execution of a task for a period of time.

$schedule->command('reminders:send')->hourly()->unlessBetween('23:00', '4:00');

### Preventing Task Overlaps

By default, scheduled tasks will be run even if the previous instance of the task is still running. To prevent this, you may use the `withoutOverlapping` method:
Expand Down

0 comments on commit 3b86b79

Please sign in to comment.