| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace FluentBooking\App\Services; |
| 4 | 4 | |
| 5 | 5 | use FluentBooking\App\Models\Calendar; |
| 6 | +use FluentBooking\Framework\Support\Arr; | |
| 6 | 7 | |
| 7 | 8 | class CalendarEventService |
| 8 | 9 | { |
| 9 | 10 | public static function processEvent($calendarEvent) |
| @@ -37,6 +38,19 @@ | ||
| 37 | 38 | $calendarEvent = self::processEvent($calendarEvent); |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | 41 | return $calendarEvents; |
| 42 | + } | |
| 43 | + | |
| 44 | + public static function isSharedCalendarEvent($calendarEvent) | |
| 45 | + { | |
| 46 | + $userId = get_current_user_id(); | |
| 47 | + | |
| 48 | + if ($calendarEvent->user_id == $userId) { | |
| 49 | + return true; | |
| 50 | + } | |
| 51 | + | |
| 52 | + $teamMembers = Arr::get($calendarEvent, 'settings.team_members', []); | |
| 53 | + | |
| 54 | + return in_array($userId, $teamMembers); | |
| 41 | 55 | } |
| 42 | 56 | } |