/** * Create a cancer detection form * */ public function createDetectionForm(Request $request) { $detectionForm['name'] = $request->input('name'); $detectionForm['description'] = $request->input('description'); $detectionForm['cancerId'] = $request->input('cancerId'); $detectionForm['createdBy'] = $request->input('createdBy'); try { $result = DetectionForm::create($detectionForm); } catch (\Exception $e) { return response()->json(['error' => ['message' => 'Could not create cancer detection form' . $e->getMessage(), 'code' => 101]]); } return response()->json(['result' => $result]); }
/** * 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('detection_form')->truncate(); DetectionForm::create(['id' => 1, 'name' => 'Throat Cancer Detection Form', 'description' => 'This form contains regarding diagnosis of Throat Cancer', 'cancerId' => 1, 'createdBy' => 1]); DB::statement('SET FOREIGN_KEY_CHECKS = 1'); // enable foreign key constraints }