Exemplo n.º 1
0
 public function attendMeeting($group)
 {
     // next meeting date
     $next_meeting_date = date(date('Y-m-d', strtotime('next ' . $group->weekdays[(int) $group->meeting_weekday])) . " " . $group->meeting_time);
     // check if a meeting entry exists for the next meeting date, if not create a new one
     $next_meeting = \App\Groupmeeting::firstOrCreate(['group_id' => $group->id, 'meeting_date' => $next_meeting_date]);
     if (!$next_meeting) {
         error_log("Could not find or create a meeting for the {$group->name} group");
         throw new \Exception("Could not find or create a meeting for the {$group->name} group");
     }
     // add entry if one doesn't exist yet
     $user = \Auth::user();
     $user_attendance = \App\Groupmeetingattendees::firstOrCreate(['meeting_id' => $next_meeting->id, 'user_id' => $user->id]);
     if (!$user_attendance) {
         error_log("Could not find or create a meeting attendance entry for the {$group->name} group");
         throw new \Exception("Could not find or create a meeting attendance entry for the {$group->name} group");
     }
     return redirect("/dashboard");
 }