我對laravel 5.4.i新開發的search_code控制器是這樣的。Laravel 5控制器返回值不工作,因爲我想
public function search_code(Request $request){
$query = $request->search;
$queryType = $request->institute; // 'id' or 'name'
$items = DB::table('registerdetails');
if($queryType == 'id'){
$items = $items->where('trainee_id', 'LIKE',"%$query%");
}
if($queryType == 'full_name'){
$items = $items->where('full_name', 'LIKE',"%$query%");
}
$items = $items->get();
return view('traineeattendance.index')->with('items',$items);
}
我需要的是$項目必須經過,並從該控制器像
return view('traineeattendance.index')->with('items',$items);
而且
return view('traineeattendance.attendance')->with('items',$items);
我如何能做到這一點有兩種不同的觀點被調用?
您可能需要閱讀HTTPS ://laravel.com/docs/5.4/views#passing-data-to-views –
先生,請你給我加上必要的代碼樣本,這將非常讚賞。我讀了,但我不明白它希望新的laravel可以請你幫忙嗎? – Dasun
「不能按我想要的方式工作」,因爲它不是以您想使用它的方式創建的(您無法從1方法返回2個視圖)。而不是試圖強迫你的方式工作,強迫自己工作的方式工具。讓你的生活更輕鬆 –