diff --git a/src/Illuminate/Console/Scheduling/ManagesFrequencies.php b/src/Illuminate/Console/Scheduling/ManagesFrequencies.php index b80f6d9a1655..de684cfdbdf3 100644 --- a/src/Illuminate/Console/Scheduling/ManagesFrequencies.php +++ b/src/Illuminate/Console/Scheduling/ManagesFrequencies.php @@ -273,6 +273,22 @@ public function monthlyOn($day = 1, $time = '0:0') return $this->spliceIntoPosition(3, $day); } + /** + * Schedule the event to run twice monthly. + * + * @param int $first + * @param int $second + * @return $this + */ + public function twiceMonthly($first = 1, $second = 16) + { + $days = $first.','.$second; + + return $this->spliceIntoPosition(1, 0) + ->spliceIntoPosition(2, 0) + ->spliceIntoPosition(3, $days); + } + /** * Schedule the event to run quarterly. * diff --git a/tests/Console/Scheduling/FrequencyTest.php b/tests/Console/Scheduling/FrequencyTest.php index 2a0fccb648d2..efaaf2ca659c 100644 --- a/tests/Console/Scheduling/FrequencyTest.php +++ b/tests/Console/Scheduling/FrequencyTest.php @@ -53,6 +53,11 @@ public function testMonthlyOn() $this->assertEquals('0 15 4 * * *', $this->event->monthlyOn(4, '15:00')->getExpression()); } + public function testTwiceMonthly() + { + $this->assertEquals('0 0 1,16 * * *', $this->event->twiceMonthly(1, 16)->getExpression()); + } + public function testMonthlyOnWithMinutes() { $this->assertEquals('15 15 4 * * *', $this->event->monthlyOn(4, '15:15')->getExpression());