8000 Make view with response status and headers · atinder-snippets/laravel@036a0ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 036a0ba

Browse files
committed
Make view with response status and headers
Add functionality to make view with response status and headers - view_with_status
1 parent 23464ca commit 036a0ba

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

laravel/response.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ public static function make($content, $status = 200, $headers = array())
5757
{
5858
return new static($content, $status, $headers);
5959
}
60+
61+
/**
62+
* Create a new response instance with status code.
63+
*
64+
* <code>
65+
* // Create a response instance with a view
66+
* return Response::view('home.no_such_page', 404);
67+
*
68+
* // Create a response instance with a view and data
69+
* return Response::view('item.no_such_page', 404, array('message' => 'Nothing found'), array('header' => 'value'));
70+
* </code>
71+
*
72+
* @param string $view
73+
* @param int $status
74+
* @param array $data
75+
* @param array $headers
76+
* @return Response
77+
*/
78+
public static function view_with_status($view, $status, $data = array(), $headers = array())
79+
{
80+
return new static(View::make($view, $data), $status, $headers);
81+
}
6082

6183
/**
6284
* Create a new response instance containing a view.

0 commit comments

Comments
 (0)
0