在laravel中以json值返回视图

时间:2017-01-10 06:51:58

标签: json laravel view return

if($listing != null) {  
    return \Response::json($listing);//return propertyees matching the search parameters
} else { 
    return \Response::json(array(["message"=>"Sorry no properties found matching your search criteria. Please try again."]),200);           
}

在json中返回视图

2 个答案:

答案 0 :(得分:0)

if($listing != null) { 
   return response()->json(['result' => $listing]);//return propertyees matching the search parameters
 }else {
   return response()->json((["message"=>"Sorry no properties found matching your search criteria. Please try again."]),200);
 }  

答案 1 :(得分:0)

if($listing != null) { 
  return response()->json($listing);
 }