Skip to content

Commit 5636016

Browse files
authored
Redirect slash (#9776)
* Add slash to `redirect()` helper method * Update pennant.md
1 parent 18dbb77 commit 5636016

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

billing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ The `subscribed` method also makes a great candidate for a [route middleware](/d
963963
{
964964
if ($request->user() && ! $request->user()->subscribed('default')) {
965965
// This user is not a paying customer...
966-
return redirect('billing');
966+
return redirect('/billing');
967967
}
968968

969969
return $next($request);

cashier-paddle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ The `subscribed` method also makes a great candidate for a [route middleware](/d
755755
{
756756
if ($request->user() && ! $request->user()->subscribed()) {
757757
// This user is not a paying customer...
758-
return redirect('billing');
758+
return redirect('/billing');
759759
}
760760

761761
return $next($request);

middleware.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ To create a new middleware, use the `make:middleware` Artisan command:
2727
php artisan make:middleware EnsureTokenIsValid
2828
```
2929

30-
This command will place a new `EnsureTokenIsValid` class within your `app/Http/Middleware` directory. In this middleware, we will only allow access to the route if the supplied `token` input matches a specified value. Otherwise, we will redirect the users back to the `home` URI:
30+
This command will place a new `EnsureTokenIsValid` class within your `app/Http/Middleware` directory. In this middleware, we will only allow access to the route if the supplied `token` input matches a specified value. Otherwise, we will redirect the users back to the `/home` URI:
3131

3232
<?php
3333

@@ -47,7 +47,7 @@ This command will place a new `EnsureTokenIsValid` class within your `app/Http/M
4747
public function handle(Request $request, Closure $next): Response
4848
{
4949
if ($request->input('token') !== 'my-secret-token') {
50-
return redirect('home');
50+
return redirect('/home');
5151
}
5252

5353
return $next($request);

pennant.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ You will notice that the closure we have defined is not expecting a `User`, but
524524

525525
```php
526526
if (Feature::for($user->team)->active('billing-v2')) {
527-
return redirect()->to('/billing/v2');
527+
return redirect('/billing/v2');
528528
}
529529

530530
// ...

requests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,11 @@ You may also use the `flashOnly` and `flashExcept` methods to flash a subset of
471471

472472
Since you often will want to flash input to the session and then redirect to the previous page, you may easily chain input flashing onto a redirect using the `withInput` method:
473473

474-
return redirect('form')->withInput();
474+
return redirect('/form')->withInput();
475475

476476
return redirect()->route('user.create')->withInput();
477477

478-
return redirect('form')->withInput(
478+
return redirect('/form')->withInput(
479479
$request->except('password')
480480
);
481481

responses.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ By default, thanks to the `Illuminate\Cookie\Middleware\EncryptCookies` middlewa
152152
Redirect responses are instances of the `Illuminate\Http\RedirectResponse` class, and contain the proper headers needed to redirect the user to another URL. There are several ways to generate a `RedirectResponse` instance. The simplest method is to use the global `redirect` helper:
153153

154154
Route::get('/dashboard', function () {
155-
return redirect('home/dashboard');
155+
return redirect('/home/dashboard');
156156
});
157157

158158
Sometimes you may wish to redirect the user to their previous location, such as when a submitted form is invalid. You may do so by using the global `back` helper function. Since this feature utilizes the [session](/docs/{{version}}/session), make sure the route calling the `back` function is using the `web` middleware group:
@@ -225,7 +225,7 @@ Redirecting to a new URL and [flashing data to the session](/docs/{{version}}/se
225225
Route::post('/user/profile', function () {
226226
// ...
227227

228-
return redirect('dashboard')->with('status', 'Profile updated!');
228+
return redirect('/dashboard')->with('status', 'Profile updated!');
229229
});
230230

231231
After the user is redirected, you may display the flashed message from the [session](/docs/{{version}}/session). For example, using [Blade syntax](/docs/{{version}}/blade):

validation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ If you do not want to use the `validate` method on the request, you may create a
559559
]);
560560

561561
if ($validator->fails()) {
562-
return redirect('post/create')
562+
return redirect('/post/create')
563563
->withErrors($validator)
564564
->withInput();
565565
}
@@ -611,7 +611,7 @@ You may use the `validateWithBag` method to store the error messages in a [named
611611

612612
If you have multiple forms on a single page, you may wish to name the `MessageBag` containing the validation errors, allowing you to retrieve the error messages for a specific form. To achieve this, pass a name as the second argument to `withErrors`:
613613

614-
return redirect('register')->withErrors($validator, 'login');
614+
return redirect('/register')->withErrors($validator, 'login');
615615

616616
You may then access the named `MessageBag` instance from the `$errors` variable:
617617

0 commit comments

Comments
 (0)