error: Showing undefined variable .in laravel 5.2 while passing two array to View
error: Showing undefined variable .in laravel 5.2 while passing two array to View
GetEstimateController.php
public function fill_dropbox(){
$data = ProcedureTreat::get(['pro_name']);
$data1 = HospitalPackage::get(['address']);
// return $this->get_estimate();
// dd($data);
return View::make('get_quote')->with('address',$data1)->with('procedureName',$data);
}
public function get_estimate($name,$addr){
// dd($name);
$HospitalPack = HospitalPackage::where(['pro' => $name, 'address' => $addr])->orderBy('treat_price', 'desc')->get()->first();
$Dropbox_fill = $this->fill_dropbox();
// dd($HospitalPack);
return View::make('get_quote')->with(compact('Dropbox_fill','HospitalPack'));
}
如果我使用
return View::make('get_quote')->with(compact('Dropbox_fill','HospitalPack'));
这一行在使用
时显示错误
return View::make('get_quote')->with(compact('HospitalPack'));
此代码未显示错误。
原来问题确实出在 fill_dropbox() 方法中的 return 语句中,所以如果你这样做的话:
public function get_estimate($name,$addr){
$HospitalPack = HospitalPackage::where(['pro' => $name, 'address' => $addr])->orderBy('treat_price', 'desc')->get()->first();
$data = ProcedureTreat::get(['pro_name']);
$data1 = HospitalPackage::get(['address']);
return View::make('get_quote')->with(compact('data', 'HospitalPack', 'data1'));
}
现在一切正常:)
public function fill_dropbox(){
$data = ProcedureTreat::get(['pro_name']);
$data1 = HospitalPackage::get(['address']);
// return $this->get_estimate();
// dd($data);
return View::make('get_quote')->with('address',$data1)->with('procedureName',$data);
}
public function get_estimate($name,$addr){
// dd($name);
$HospitalPack = HospitalPackage::where(['pro' => $name, 'address' => $addr])->orderBy('treat_price', 'desc')->get()->first();
$Dropbox_fill = $this->fill_dropbox();
// dd($HospitalPack);
return View::make('get_quote')->with(compact('Dropbox_fill','HospitalPack'));
}
如果我使用
return View::make('get_quote')->with(compact('Dropbox_fill','HospitalPack'));
这一行在使用
时显示错误return View::make('get_quote')->with(compact('HospitalPack'));
此代码未显示错误。
原来问题确实出在 fill_dropbox() 方法中的 return 语句中,所以如果你这样做的话:
public function get_estimate($name,$addr){
$HospitalPack = HospitalPackage::where(['pro' => $name, 'address' => $addr])->orderBy('treat_price', 'desc')->get()->first();
$data = ProcedureTreat::get(['pro_name']);
$data1 = HospitalPackage::get(['address']);
return View::make('get_quote')->with(compact('data', 'HospitalPack', 'data1'));
}
现在一切正常:)