jpmurray/laravel-rrule

This package is abandoned and no longer maintained. No replacement package was suggested.

A Laravel friendly package to manage date recurrence rules

3.2.1 2016-08-23 19:23 UTC

This package is auto-updated.

Last update: 2019-02-20 19:41:28 UTC


README

Latest Version on Packagist Software License StyleCI Total Downloads

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.