Laravel5响应& quot; HTTP状态代码& quot; 1& quot;无效." [英] Laravel5 Response "The HTTP status code "1" is not valid."
本文介绍了Laravel5响应& quot; HTTP状态代码& quot; 1& quot;无效."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对大型数据有大型但简单的联接查询.如果我使用 dd()
或 var_dump()
打印查询结果,则会得到结果,但是如果我传递结果数据或重定向,则会得到
I have large but simple join query for large data. If i print query result using dd()
or var_dump()
i get result, but if i pass result data or redirect i get an exception which is
"HTTP状态代码"1"无效."
"The HTTP status code "1" is not valid."
这是操作代码:
public function postSearch(Request $request)
{
$min_price = !empty($request['min_price']) ? $request['min_price'] : 500;
$max_price = !empty($request['max_price']) ? $request['max_price'] : 50000000000;
$properties = DB::table('properties')
->join('addresses', function($join) {
$join->on('properties.id', '=', 'addresses.property_id');
})
->where('status', '=', 1)
->where('category', '=', $request['search_category'])
->where('type', '=', $request['contract'])
->where('city', '=', $request['search_city'])
->where('area', '=', $request['property_area'])
->where('bed_room', '=', $request['search_bedroom'])
->where('bath_room', '=', $request['bath_room'])
->whereBetween('price', [$min_price, $max_price])
->orderBy('properties.updated_at', 'desc')
->paginate(15);
try {
if(!empty($properties))
{
return Redirect::to('property/search', compact('properties'));
}
else
{
return Redirect::to('/')->with('message', PropertyHelper::formatMessage(trans('property.property_not_found'), 'danger'));
}
}
catch(\Exception $ex) {
dd($ex->getMessage());
}
}
推荐答案
我想您尝试在搜索后显示搜索结果.问题是这条线.
I guess you try to show the search results after searching. The problem is this line.
return Redirect::to('property/search', compact('properties'));
获得搜索结果后,您应该调用视图,而不是重定向.
After you get the search result you should call a view, not redirect.
return view('property.search', compact('properties'));
但是请确保您具有视图文件.
But make sure you have the view file.
这篇关于Laravel5响应& quot; HTTP状态代码& quot; 1& quot;无效."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文