Can you show the routes for these methods?
Dec 12, 2021
30
Level 1
Half of the parts from my form is sent to the table, and the other half don't
I have two forms that I want to be sent to one table called "medical_records". Some of the parts of the form are being sent, and the other don't.
This is the Controller of the first form:
class HealthPredispositionQuestionnaireController extends Controller
{
public function index()
{
return Inertia::render('HealthPredispositionQuestionnaire/Index', [
'questionnaire' => HealthPredispositionQuestionnaire::all(),
]);
}
public function questionnaireForm(Request $request)
{
$validated = $this->validate($request, [
'past_medical_problems' => 'required',
'current_medications' => 'required',
'level_of_physical_activity' => 'required',
'blood_pressure' => 'required',
'body_temperature' => 'required',
'heart_rate' => 'required',
'respiration_rate' => 'required',
'height' => 'required',
'weight' => 'required',
'additional_notes' => 'required',
]);
$validated['user_id'] =\Auth::user()->id;
$record = MedicalRecord::create($validated);
$record = MedicalRecord::create($request->all());
return Inertia::render('SymptomsQuestionnaireQuestionnaire/Index', [
'medicalRecordId' => $record->id
]);
}
}
And this is the Controller of the second form:
class SymptomsQuestionnaireController extends Controller
{
public function index()
{
return Inertia::render('SymptomsQuestionnaire/Index', [
'symptoms' => Symptoms::all(),
]);
}
public function symptomsForm(Request $request)
{
$validation = $this->validate($request, [
'symptoms' => 'required',
'start_of_the_problem' => 'required',
'area_of_the_pain' => 'required',
'additional_problems' => 'required'
]);
$record = MedicalRecord::find($request->mrid);
$record->symptoms = $request->symptoms;
$record->start_of_the_problem = $request->start_of_the_problem;
$record->area_of_the_pain = $request->area_of_the_pain;
$record->additional_problems = $request->additional_problems;
$record->save();
dd($record);
return Inertia::render('SymptomsQuestionnaire/Index', [
'symptoms' => Symptoms::all(),
]);
}
}
This is the model MedicalRecord:
class MedicalRecord extends Model
{
use HasFactory;
public function user()
{
return $this->belongsTo(User::class);
}
use HasFactory;
public $fillable = [
'user_id',
'past_problems_and_surgeries',
'current_medications_usage',
'level_of_physical_activity',
'blood_pressure',
'body_temperature',
'heart_rate',
'respiration_rate',
'height',
'weight',
'additional_notes',
'symptoms',
'when_problem_started',
'pain_area',
'pain_intensity',
'additional_symptoms',
];
}
Level 102
@TikTina you say
half of the information from the first form is being sent I assume this means this data is being saved?
$validated = $this->validate($request, [
'past_medical_problems' => 'required',
'current_medications' => 'required',
'level_of_physical_activity' => 'required',
'blood_pressure' => 'required',
'body_temperature' => 'required',
'heart_rate' => 'required',
'respiration_rate' => 'required',
'height' => 'required',
'weight' => 'required',
'additional_notes' => 'required',
]);
Please or to participate in this conversation.