GetEstimateController.php如何laravel調用一個函數在同一個控制器中的另一個函數內部5.2
class GetEstimationController extends Controller
{
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,$address){
$data = HospitalPackage::where(['pro' => 'name', 'address' => 'address'])->get();
$Dropbox_fill = $this->fill_dropbox();
// dd($Dropbox_fill);
return View::make('get_quote')->with('HospitalPack',$data);
}
}
routes.php文件
Route::get('/',[
'uses' => '[email protected]_dropbox',
'as' => 'fill.dropbox'
]);
Route::any('/find/{name}/{address}',[
'uses' => '[email protected]_estimate',
'as' => 'get.estimate'
]);
get_quote.blade.php
@if(isset($procedureName))
@foreach($procedureName as $key => $data)
<option value="{{$data->pro_name}}">{{$data->pro_name}}</option>
@endforeach
@endif
@if(isset($address))
@foreach($address as $key => $add)
<option value="{{$add->address}}">{{$add->address}}</option>
@endforeach
@endif
我想在get_estimate
函數裏面調用fill_dropbox
函數並想發送數據到再次。
使用$Dropbox_fill = $this->fill_dropbox();
我得到的數據
View {#155 ▼
#factory: Factory {#141 ▶}
#engine: CompilerEngine {#148 ▶}
#view: "get_quote"
#data: array:2 [▼
"address" => Collection {#2507 ▼
#items: array:1382 [▼
0 => HospitalPackage {#2508 …24}
1 => HospitalPackage {#2509 …24}
2 => HospitalPackage {#2510 …24}
3 => HospitalPackage {#2511 …24}
}
"procedureName" => Collection {#1124 ▶}
]
#path: "C:\wamp\www\IIMTC\bmmt_new\resources\views/get_quote.blade.php"
}
所以我怎麼能與以前foreach
訪問它get_quote.blade.php
。
返回查看視圖訪問::讓( 'get_quote') - > with('data',['HospitalPack'=> $ data,'Dropbox_fill'=> $ Dropbox_fill]); – JYoThI
試試我的答案@Giridhari Lal – JYoThI