PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.5.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.5.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
← All changes | app/Models/CalendarSlot.php +37 -9 2.1.1 → 2.5.0 View file →
@@ -138,8 +138,18 @@
138 138 {
139 139 return $this->event_type == 'group_event';
140 140 }
141 141
142 + /**
143 + * Every value event_type can hold, on both fcal_calendar_slots and fcal_bookings.
144 + *
145 + * @return array
146 + */
147 + public static function getEventTypes()
148 + {
149 + return ['single', 'group', 'round_robin', 'collective', 'single_event', 'group_event'];
150 + }
151 +
142 152 public function isRoundRobin()
143 153 {
144 154 return $this->event_type == 'round_robin';
145 155 }
@@ -231,11 +241,19 @@
231 241 {
232 242 $teamMembers = [];
233 243 $teamMemberIds = $this->getHostIds();
234 244
245 + cache_users($teamMemberIds);
246 +
247 + $calendars = Calendar::whereIn('user_id', $teamMemberIds)
248 + ->where('type', 'simple')
249 + ->orderBy('id', 'desc')
250 + ->with(['metas', 'user', 'user.metas'])
251 + ->get()
252 + ->keyBy('user_id');
253 +
235 254 foreach ($teamMemberIds as $teamMemberId) {
236 - $calendar = Calendar::where('user_id', $teamMemberId)->where('type', 'simple')->first();
237 - if ($calendar) {
255 + if ($calendar = $calendars->get($teamMemberId)) {
238 256 $teamMembers[] = $calendar->getAuthorProfile($public);
239 257 }
240 258 }
241 259
@@ -438,10 +456,12 @@
438 456 return Arr::get($schedule, 'value.timezone', 'UTC');
439 457 }
440 458
441 459 if ($this->availability_type == 'existing_schedule') {
442 - $schedule = Availability::findOrFail($this->availability_id);
443 - return Arr::get($schedule, 'value.timezone', 'UTC');
460 + $schedule = Availability::find($this->availability_id);
461 + if ($schedule) {
462 + return Arr::get($schedule, 'value.timezone', 'UTC');
463 + }
444 464 }
445 465
446 466 return $this->calendar->author_timezone;
447 467 }
@@ -635,9 +655,11 @@
635 655 if (!$conditions || empty($conditions['unit'])) {
636 656 return 0;
637 657 }
638 658
639 - return strtotime('+' . $conditions['value'] . ' ' . $conditions['unit'], 0) - strtotime('+0 seconds', 0);
659 + $value = max(0, (int) Arr::get($conditions, 'value', 0));
660 +
661 + return strtotime('+' . $value . ' ' . $conditions['unit'], 0) - strtotime('+0 seconds', 0);
640 662 }
641 663
642 664 public function getHostIds($hostId = null)
643 665 {
@@ -813,8 +835,10 @@
813 835
814 836 $conditionTime = $conditionValue * 60;
815 837 if ($conditionUnit == 'hours') {
816 838 $conditionTime = $conditionTime * 60;
839 + } elseif ($conditionUnit == 'days') {
840 + $conditionTime = $conditionTime * 60 * 24;
817 841 }
818 842
819 843 return $bookingStartTime - $bookingCreatedTime < $conditionTime;
820 844 }
@@ -1061,10 +1085,12 @@
1061 1085 return $this->getProcessedWeeklySlots($schedule);
1062 1086 }
1063 1087
1064 1088 if ($this->availability_type === 'existing_schedule') {
1065 - $schedule = Availability::findOrFail($this->availability_id);
1066 - return $this->getProcessedWeeklySlots($schedule);
1089 + $schedule = Availability::find($this->availability_id);
1090 + if ($schedule) {
1091 + return $this->getProcessedWeeklySlots($schedule);
1092 + }
1067 1093 }
1068 1094
1069 1095 $scheduleData = Arr::get($this->settings, 'weekly_schedules', []);
1070 1096 $schedule = SanitizeService::weeklySchedules($scheduleData, 'UTC', $this->calendar->author_timezone);
@@ -1078,10 +1104,12 @@
1078 1104 return $this->getProcessedDateOverrides($schedule);
1079 1105 }
1080 1106
1081 1107 if ($this->availability_type === 'existing_schedule') {
1082 - $schedule = Availability::findOrFail($this->availability_id);
1083 - return $this->getProcessedDateOverrides($schedule);
1108 + $schedule = Availability::find($this->availability_id);
1109 + if ($schedule) {
1110 + return $this->getProcessedDateOverrides($schedule);
1111 + }
1084 1112 }
1085 1113
1086 1114 $scheduleData = Arr::get($this->settings, 'date_overrides', []);
1087 1115 $schedule = SanitizeService::slotDateOverrides($scheduleData, 'UTC', $this->calendar->author_timezone);