I’ve already passed data to the destination page using compact by a method. now I want to pass data to the destination page using compact again. Is there any problem for that? Firstly I tried to use one method instead of two method to send data using compact. but there was an argument error. Now when I tried to fetch data using second method still an error occurs which is unidentified variable. how do I solve the issue.
here is controller :
First method. Which is worked already.
public function doctors()
{
// Fetch all doctor information
$doctor_info = addDoctor::all();
return view('/Doctors/doctors',compact('doctor_info'));
}
Second Method : Not working
public function edit($id){
$to_be_edited = addDoctor::find($id);
return view('/Doctors/doctors',compact('to_be_edited'));
}
Destination Page :
Error : $to_be_edited
undefined variable
5