From 036a0bab0bd05cf2f8086363c35adc104a7cf631 Mon Sep 17 00:00:00 2001 From: "dr.dimitru" Date: Tue, 16 Apr 2013 03:28:55 +0400 Subject: [PATCH] Make view with response status and headers Add functionality to make view with response status and headers - view_with_status --- laravel/response.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/laravel/response.php b/laravel/response.php index f3508358..242deab0 100644 --- a/laravel/response.php +++ b/laravel/response.php @@ -57,6 +57,28 @@ public static function make($content, $status = 200, $headers = array()) { return new static($content, $status, $headers); } + + /** + * Create a new response instance with status code. + * + * + * // Create a response instance with a view + * return Response::view('home.no_such_page', 404); + * + * // Create a response instance with a view and data + * return Response::view('item.no_such_page', 404, array('message' => 'Nothing found'), array('header' => 'value')); + * + * + * @param string $view + * @param int $status + * @param array $data + * @param array $headers + * @return Response + */ + public static function view_with_status($view, $status, $data = array(), $headers = array()) + { + return new static(View::make($view, $data), $status, $headers); + } /** * Create a new response instance containing a view.