Skip to content

Commit 499d81b

Browse files
committed
docs: Docs updated for helper functions
1 parent fc87949 commit 499d81b

File tree

1 file changed

+71
-40
lines changed

1 file changed

+71
-40
lines changed

README.md

Lines changed: 71 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,46 +26,77 @@ composer require infyomlabs/laravel-calendar-events
2626
## Usage
2727

2828
``` php
29-
use InfyOm\LaravelCalendarEvents\CalendarEvent;
30-
use InfyOm\LaravelCalendarEvents\CalendarEventRecurrencePattern;
31-
32-
$event = new CalendarEvent([
33-
[
34-
'id' => 1,
35-
'title' => 'Daily Repeat End on 30 Jan',
36-
'description' => 'Daily Repeat End on 30 Jan',
37-
'start_date' => '2021-01-10',
38-
'end_date' => '2021-01-20', // nullable
39-
'start_time' => '10:00:00',
40-
'end_time' => '12:00:00',
41-
'is_full_day' => false,
42-
'is_recurring' => true,
43-
'location' => 'Surat, India', // extra field. It will be automatically added to meta
44-
'meta' => [
45-
'ticket_required' => true
46-
]
47-
]
48-
]);
49-
50-
$event->recurring_pattern = new CalendarEventRecurrencePattern([
51-
'recurring_type' => RecurringFrequencyType::RECURRING_TYPE_DAILY,
52-
'max_occurrences' => 10, // Maximum 10 Occurrences
53-
'repeat_interval' => 1, // Repeat Daily
54-
'repeat_by_days' => ["MO", "WE", "SU"], // only repeat on Monday, Wednesday and Sunday
55-
'repeat_by_months' => [],
56-
]);
57-
58-
// Retrieve next 5 events. Returns CalendarEvent array.
59-
$event->getNextEvents(5);
60-
61-
// Retrieve all events between 5th Jan to 15th Jan. Returns CalendarEvent array.
62-
$event->getEventsBetween('2021-01-05', '2021-01-15');
63-
64-
// Retrieve next 2 Occurrences. Returns \Recurr\Recurrence array
65-
$event->getNextOccurrences(2);
66-
67-
// If you Laravel Eloquent model matches the field names with above field name
68-
$event = new CalendarEvent($calendarModle);
29+
use InfyOm\LaravelCalendarEvents\CalendarEvent;
30+
use InfyOm\LaravelCalendarEvents\CalendarEventRecurrencePattern;
31+
32+
$event = new CalendarEvent([
33+
[
34+
'id' => 1,
35+
'title' => 'Daily Repeat End on 30 Jan',
36+
'description' => 'Daily Repeat End on 30 Jan',
37+
'start_date' => '2021-01-10',
38+
'end_date' => '2021-01-20', // nullable
39+
'start_time' => '10:00:00',
40+
'end_time' => '12:00:00',
41+
'is_full_day' => false,
42+
'is_recurring' => true,
43+
'location' => 'Surat, India', // extra field. It will be automatically added to meta
44+
'meta' => [
45+
'ticket_required' => true
46+
]
47+
]
48+
]);
49+
50+
$event->recurring_pattern = new CalendarEventRecurrencePattern([
51+
'recurring_type' => RecurringFrequencyType::RECURRING_TYPE_DAILY,
52+
'max_occurrences' => 10, // Maximum 10 Occurrences
53+
'repeat_interval' => 1, // Repeat Daily
54+
'repeat_by_days' => ["MO", "WE", "SU"], // only repeat on Monday, Wednesday and Sunday
55+
'repeat_by_months' => [],
56+
]);
57+
58+
// Retrieve next 5 events. Returns CalendarEvent array.
59+
$event->getNextEvents(5);
60+
61+
// Retrieve all events between 5th Jan to 15th Jan. Returns CalendarEvent array.
62+
$event->getEventsBetween('2021-01-05', '2021-01-15');
63+
64+
// Retrieve next 2 Occurrences. Returns \Recurr\Recurrence array
65+
$event->getNextOccurrences(2);
66+
67+
// If you Laravel Eloquent model matches the field names with above field name
68+
$event = new CalendarEvent($calendarModle);
69+
```
70+
71+
You can also call direct functions on `CalendarEvent` class,
72+
73+
```php
74+
$event = new CalendarEvent([
75+
[
76+
'id' => 1,
77+
'title' => 'Daily Repeat End on 30 Jan',
78+
'description' => 'Daily Repeat End on 30 Jan',
79+
'start_time' => '10:00:00',
80+
'end_time' => '12:00:00',
81+
'location' => 'Surat, India', // extra field. It will be automatically added to meta
82+
'meta' => [
83+
'ticket_required' => true
84+
]
85+
]
86+
]);
87+
88+
$event->setStartDate(\Carbon\Carbon::parse('2021-01-10'));
89+
$event->setEndDate(\Carbon\Carbon::parse('2021-01-20'));
90+
$event->makeFullDay();
91+
$event->makeRecurring();
92+
93+
$recurringPattern = new CalendarEventRecurrencePattern();
94+
$recurringPattern->repeatDaily();
95+
$recurringPattern->setMaxOccurrences(10);
96+
$recurringPattern->setRepeatInterval(2);
97+
$recurringPattern->setRepeatDays(["MO", "WE", "SU"]);
98+
99+
$event->recurring_pattern = $recurringPattern;
69100
```
70101

71102
### Testing

0 commit comments

Comments
 (0)