RecurrenceData DTO
RecurrenceData provides a clean interface for working with recurrence patterns:
use Andreia\FilamentRecurrence\Data\RecurrenceData;
use Carbon\Carbon;
// Create from array
$data = RecurrenceData::fromArray([
'frequency' => 'WEEKLY',
'interval' => 2,
'start_date' => Carbon::now(),
'by_day' => ['MO', 'WE', 'FR'],
'count' => 10,
]);
// Create from RRULE string
$data = RecurrenceData::fromRule('FREQ=DAILY;INTERVAL=1;COUNT=5');
// Convert to RRULE string
$rule = $data->toRule();
// Human-readable description
$description = $data->toHumanReadable(); // "Every 2 weeks on Monday, Wednesday, Friday, 10 times"
// Get occurrences
$occurrences = $data->getOccurrences(limit: 5);
// Convert to array
$array = $data->toArray();
Daily patterns
// Every day
[
'frequency' => 'DAILY',
'interval' => 1,
'start_date' => Carbon::now(),
]
// Every 3 days, 10 times
[
'frequency' => 'DAILY',
'interval' => 3,
'count' => 10,
]
Weekly patterns
// Every week on Monday and Friday
[
'frequency' => 'WEEKLY',
'interval' => 1,
'by_day' => ['MO', 'FR'],
]
// Every 2 weeks on weekdays
[
'frequency' => 'WEEKLY',
'interval' => 2,
'by_day' => ['MO', 'TU', 'WE', 'TH', 'FR'],
]
Monthly patterns
// Every month on the 15th
[
'frequency' => 'MONTHLY',
'interval' => 1,
'by_month_day' => [15],
]
// Every month on the first Monday
[
'frequency' => 'MONTHLY',
'interval' => 1,
'by_day' => ['MO'],
'by_set_pos' => 1,
]
// Every month on the last Friday
[
'frequency' => 'MONTHLY',
'interval' => 1,
'by_day' => ['FR'],
'by_set_pos' => -1,
]
Yearly patterns
// Every year on January 1st
[
'frequency' => 'YEARLY',
'interval' => 1,
'by_month' => [1],
'by_month_day' => [1],
]
// Every year in June and December
[
'frequency' => 'YEARLY',
'interval' => 1,
'by_month' => [6, 12],
]

