A Laravel friendly package to manage date recurrence rules
A simple helper to generate date occurences more fluently, using simshaun/recurr.
This is my first package. I actually built this to get to gain a bit more know-how about packages. It might be useful. It might not. It might be badly constructed. It might not. Honestly, I'll try to maintain and improve it over time, but please bear with me as it's been built more to learn that to be the perfect package.
And on that note: PRs are hapilly welcomed!
Check this tag in the issues.
$ composer require jpmurray/laravel-rrule
$recurrence = new Recurrence(); //of course, you can chain all those methods! $recurrence->setFrequency('weekly'); // Either one of `yearly`, `monthly`, `weekly`, `daily`, `hourly`, `minutly`, `secondly` $recurrence->setCount(20); // the number of occurences we want. Cannot be used with `setUntil()` $recurrence->setInterval(1); // every Nth time $recurrence->setStart(Carbon::parse('August 9th 2016 21:18:00')); // a carbon object for when to start the occurences $recurrence->setEnd(Carbon::parse('August 9th 2016 22:00:10')); // a carbon object for when to end the occurences $recurrence->setDays([ ['sunday', null], ['tuesday', -2], ['friday', 3], ]); // the first is the day of the occurence, the other is the position (eg: -2: second to last; 3: third; null: not set) $recurrence->setMonths([ 'january', 'march', 'october', 'december' ]); // months of the occurences $recurrence->setLang('fr'); // for output to text. Defaults to english. Accepts ISO 639-1 language codes $recurrence->setFrom(Carbon::now()->subMonth()); // calculate occurences from this date. $recurrence->setUntil(Carbon::now()->addMonths(2)); // calculate occurences until this date. Cannot be used with `setCount()` $recurrence->build(); //will save object and generate the outputs
Those next methods are not chainable:
$recurrence->getToText(); // returns the `toText` value of current rules. eg: "weekly in January, March, October and December on the Sunday, 2nd to the last Tuesday and 3rd Friday for 5 times" $recurrence->getOccurences(); // returns a collection of Carbon object for each occurence with current rules
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email firstname.lastname@example.org instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.