/** * Run the database seeds. * * @return void */ public function run() { if (App::environment() === 'production') { exit('Do not seed in production environment'); } DB::statement('SET FOREIGN_KEY_CHECKS = 0'); // disable foreign key constraints DB::table('screenings')->truncate(); Screening::create(['id' => 1, 'patientId' => 1, 'volunteerId' => 2, 'eventId' => 2]); DB::statement('SET FOREIGN_KEY_CHECKS = 1'); // enable foreign key constraints }
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)]); }