Skip to content

Commit

Permalink
Redirect slash (#9776)
Browse files Browse the repository at this point in the history
* Add slash to `redirect()` helper method

* Update pennant.md
  • Loading branch information
TENIOS authored Jul 18, 2024
1 parent 18dbb77 commit 5636016
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ The `subscribed` method also makes a great candidate for a [route middleware](/d
{
if ($request->user() && ! $request->user()->subscribed('default')) {
// This user is not a paying customer...
return redirect('billing');
return redirect('/billing');
}

return $next($request);
Expand Down
2 changes: 1 addition & 1 deletion cashier-paddle.md
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ The `subscribed` method also makes a great candidate for a [route middleware](/d
{
if ($request->user() && ! $request->user()->subscribed()) {
// This user is not a paying customer...
return redirect('billing');
return redirect('/billing');
}

return $next($request);
Expand Down
4 changes: 2 additions & 2 deletions middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To create a new middleware, use the `make:middleware` Artisan command:
php artisan make:middleware EnsureTokenIsValid
```

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:
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:

<?php

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

return $next($request);
Expand Down
2 changes: 1 addition & 1 deletion pennant.md
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ You will notice that the closure we have defined is not expecting a `User`, but

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

// ...
Expand Down
4 changes: 2 additions & 2 deletions requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,11 @@ You may also use the `flashOnly` and `flashExcept` methods to flash a subset of

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:

return redirect('form')->withInput();
return redirect('/form')->withInput();

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

return redirect('form')->withInput(
return redirect('/form')->withInput(
$request->except('password')
);

Expand Down
4 changes: 2 additions & 2 deletions responses.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ By default, thanks to the `Illuminate\Cookie\Middleware\EncryptCookies` middlewa
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:

Route::get('/dashboard', function () {
return redirect('home/dashboard');
return redirect('/home/dashboard');
});

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:
Expand Down Expand Up @@ -225,7 +225,7 @@ Redirecting to a new URL and [flashing data to the session](/docs/{{version}}/se
Route::post('/user/profile', function () {
// ...

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

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):
Expand Down
4 changes: 2 additions & 2 deletions validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ If you do not want to use the `validate` method on the request, you may create a
]);

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

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`:

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

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

Expand Down

0 comments on commit 5636016

Please sign in to comment.