Php Laravel返回带有参数的响应
我想这样做:Php Laravel返回带有参数的响应,php,laravel-4,blade,param,Php,Laravel 4,Blade,Param,我想这样做: return Response::view('survey.do') //->with('theme',$survey->theme); ->header('Cache-Control', 'no-cache, must-revalidate') ->header('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT'); $data = ar
return Response::view('survey.do')
//->with('theme',$survey->theme);
->header('Cache-Control', 'no-cache, must-revalidate')
->header('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT');
$data = array('theme' => $survey->theme);
$headres = array(
'Cache-Control' => 'no-cache, must-revalidate',
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT'
);
return Response::view('survey.do', $data, '200', $headres);
它说在视图中找不到主题定义,问题是当我这样做时:
View::make('survey.do')->with('theme',$survey->theme)
它确实可以工作,但我无法访问
http响应
标头,我如何才能实现这一点?而不是使用和标头
传递数组,如下所示:
return Response::view('survey.do')
//->with('theme',$survey->theme);
->header('Cache-Control', 'no-cache, must-revalidate')
->header('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT');
$data = array('theme' => $survey->theme);
$headres = array(
'Cache-Control' => 'no-cache, must-revalidate',
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT'
);
return Response::view('survey.do', $data, '200', $headres);
这将起作用,因为这是响应
类(Facade)中的方法签名/头:
在本例中,它调用该类的make
方法,如下所示:
public static function make($content = '', $status = 200, array $headers = array())
{
return new IlluminateResponse($content, $status, $headers);
}
你走得很好。首先将视图标题放置在变量中(&U):
$view = View::make('survey.do')
->with('theme', $survey->theme);
$response = Response::make($view, $status);
$response->header('Cache-Control', 'no-cache, must-revalidate')
->header('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT');
return $response;