我不知道该问题的标题。请不要贬低或关闭它。
我得到的错误是:
searchController.php第148行中的FatalErrorException: 语法错误,意外“公共”(T_PUBLIC)
if($criteria == 'courses'){
//return redirect()->back(); <-- if I uncomment this code and remove the code from "$result" all the way down to the second "return view" code, I don't get an error.
$result=schools::whereRaw("MATCH(undergradcourses,postgradcourses) AGAINST('$searchItem')")->where('status','')->get();
if(count($result)>0){
$count=count($result);
return view('schools', array('result' => $result))->with(array('searchItem'=>$searchItem,'criteria'=>$criteria,'count'=>$count))->with('searchItem',$searchItem);
}
else{
return view('schools')->with(array('msg'=>'Oops, No result found','count'=>'0','searchItem'=>$searchItem,'criteria'=>$criteria));
}
}
//sort search
public function sortsearch(Request $request){ <-- this is line 148
如果您可以从我上面的评论中看到,如果我取消注释return redirect()->back();
并将其余代码从$result
移除到else
代码,则不会显示错误并且页面有效细
我从上面的代码中复制了这段代码(它专注于处理学校的请求),这些代码运行良好:
public function postsearch(Request $request){
$searchItem=$request['searchItem'];
$criteria=$request['criteria'];
if($criteria == 'schools'){
$result=schools::whereRaw("MATCH(name,describtion) AGAINST('$searchItem')")->where('status','')->get();
if(count($result)>0){
$count=count($result);
return view('schools', array('result' => $result))->with(array('searchItem'=>$searchItem,'criteria'=>$criteria,'count'=>$count))->with('searchItem',$searchItem);
}
else{
return view('schools')->with(array('msg'=>'Oops, No result found','count'=>'0','searchItem'=>$searchItem,'criteria'=>$criteria));
}
}