Skip to content

Commit 0bad022

Browse files
committed
document to action
1 parent b1a0e4a commit 0bad022

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

helpers.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
152152
[route](#method-route)
153153
[secure_asset](#method-secure-asset)
154154
[secure_url](#method-secure-url)
155+
[to_action](#method-to-action)
155156
[to_route](#method-to-route)
156157
[uri](#method-uri)
157158
[url](#method-url)
@@ -2100,6 +2101,28 @@ $url = secure_url('user/profile');
21002101
$url = secure_url('user/profile', [1]);
21012102
```
21022103

2104+
<a name="method-to-action"></a>
2105+
#### `to_action()` {.collection-method}
2106+
2107+
The `to_action` function generates a [redirect HTTP response](/docs/{{version}}/responses#redirects) for a given controller action:
2108+
2109+
```php
2110+
use App\Http\Controllers\UserController;
2111+
2112+
return to_action([UserController::class, 'show'], ['user' => 1]);
2113+
```
2114+
2115+
If necessary, you may pass the HTTP status code that should be assigned to the redirect and any additional response headers as the third and fourth arguments to the `to_action` method:
2116+
2117+
```php
2118+
return to_action(
2119+
[UserController::class, 'show'],
2120+
['user' => 1],
2121+
302,
2122+
['X-Framework' => 'Laravel']
2123+
);
2124+
```
2125+
21032126
<a name="method-to-route"></a>
21042127
#### `to_route()` {.collection-method}
21052128

0 commit comments

Comments
 (0)