jpmurray / laravel-rrule
A Laravel friendly package to manage date recurrence rules
Installs: 2 153
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 1
Forks: 7
Open Issues: 7
Requires
- php: ~5.6|~7.0
- illuminate/support: ~5.1
- nesbot/carbon: ^1.21
- simshaun/recurr: ^0.6.3
- tightenco/collect: ^5.2
Requires (Dev)
- phpunit/phpunit: ~4.0||~5.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
README
A simple helper to generate date occurences more fluently, using simshaun/recurr.
Nota Bene
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!
Roadmap
Check this tag in the issues.
Install
Via Composer
$ composer require jpmurray/laravel-rrule
Usage
$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
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email himself@jpmurray.net instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.