Skip to content

Commit e5bb44c

Browse files
committed
feat: add redirect exit
1 parent af44977 commit e5bb44c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Response.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function die($data, int $code = 500)
263263
* @param string|array $url The redirect destination
264264
* @param int $status The redirect HTTP status code
265265
*/
266-
public function redirect($url, int $status = 302)
266+
public function redirect($url, int $status = 302, bool $exit = true)
267267
{
268268
if (is_array($url)) {
269269
$url = app()->route($url[0]);
@@ -280,6 +280,10 @@ public function redirect($url, int $status = 302)
280280

281281
Headers::status($status);
282282
Headers::set('Location', $url, true, $status);
283+
284+
if ($exit) {
285+
exit($status);
286+
}
283287
}
284288

285289
/**

0 commit comments

Comments
 (0)