Пример #1
0
 private function fetchScreening($eventId, $patientId, $volunteerId)
 {
     $screening = DB::table('screenings')->select('screenings.id')->where('eventId', '=', $eventId)->where('patientId', '=', $patientId)->where('volunteerId', '=', $volunteerId)->get();
     if ($screening == null) {
         try {
             $screening = new Screening();
             $screening['eventId'] = $eventId;
             $screening['patientId'] = $patientId;
             $screening['volunteerId'] = $volunteerId;
             $screening->save();
         } catch (\Exception $e) {
             return response()->json(['error' => ['message' => 'Could not save screening', 'code' => 101]]);
         }
     }
     return response()->json(['screening' => reset($screening)]);
 }