Skip to content

Commit e8e6996

Browse files
Translation redirects.md for commit 2a0615c0b2833c9a6c80052c6896071fa525d0fc (LaravelRUS#6)
1 parent 16e6816 commit e8e6996

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

redirects.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
# HTTP Redirects
1+
git 2a0615c0b2833c9a6c80052c6896071fa525d0fc
22

3-
- [Creating Redirects](#creating-redirects)
4-
- [Redirecting To Named Routes](#redirecting-named-routes)
5-
- [Redirecting To Controller Actions](#redirecting-controller-actions)
6-
- [Redirecting With Flashed Session Data](#redirecting-with-flashed-session-data)
3+
---
4+
5+
# HTTP переадресация
6+
7+
- [Создание переадресации](#creating-redirects)
8+
- [Переадресация на именованные маршруты](#redirecting-named-routes)
9+
- [Переадресация на методы контроллера](#redirecting-controller-actions)
10+
- [Переадресация с данными сеанса](#redirecting-with-flashed-session-data)
711

812
<a name="creating-redirects"></a>
9-
## Creating Redirects
13+
## Создание переадресации
1014

11-
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:
15+
Переадресация является экземпляром класса `Illuminate\Http\RedirectResponse` и содержит в ответе правильные заголовки, необходимые для перенаправления пользователя на другой URL. Есть несколько способов сгенерировать экземпляр `RedirectResponse`. Самый простой способ — использовать глобальный помощник `redirect`:
1216

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

17-
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 or has all of the session middleware applied:
21+
Иногда необходимо перенаправить пользователя в его предыдущее местоположение, например, когда отправленная форма недействительна. Это можно сделать с помощью глобальной вспомогательной функции `back`. Поскольку эта функция использует [сессии](/docs/{{version}}/session), убедитесь, что маршрут, вызывающий функцию `back`, использует группу посредников` web` или применяет все необходимые посредники сессии:
1822

1923
Route::post('/user/profile', function () {
2024
// Validate the request...
@@ -23,31 +27,31 @@ Sometimes you may wish to redirect the user to their previous location, such as
2327
});
2428

2529
<a name="redirecting-named-routes"></a>
26-
## Redirecting To Named Routes
30+
## Переадресация на именованные маршруты
2731

28-
When you call the `redirect` helper with no parameters, an instance of `Illuminate\Routing\Redirector` is returned, allowing you to call any method on the `Redirector` instance. For example, to generate a `RedirectResponse` to a named route, you may use the `route` method:
32+
Когда вы вызываете помощник `redirect` без параметров, возвращается экземпляр `Illuminate\Routing\Redirector`, что позволяет вам вызывать любой метод в экземпляре `Redirector`. Например, чтобы сгенерировать `RedirectResponse` на именованный маршрут, вы можете использовать метод route:
2933

3034
return redirect()->route('login');
3135

32-
If your route has parameters, you may pass them as the second argument to the `route` method:
36+
Если ваш маршрут имеет параметры, вы можете передать их в качестве второго аргумента методу `route`:
3337

3438
// For a route with the following URI: profile/{id}
3539

3640
return redirect()->route('profile', ['id' => 1]);
3741

3842
<a name="populating-parameters-via-eloquent-models"></a>
39-
#### Populating Parameters Via Eloquent Models
43+
#### Передача параметров через модели Eloquent
4044

41-
If you are redirecting to a route with an "ID" parameter that is being populated from an Eloquent model, you may pass the model itself. The ID will be extracted automatically:
45+
Если вы перенаправляете на маршрут с параметром "ID", который заполняется из модели Eloquent, вы можете передать саму модель. ID будет извлечен автоматически:
4246

4347
// For a route with the following URI: profile/{id}
4448

4549
return redirect()->route('profile', [$user]);
4650

47-
If you would like to customize the value that is placed in the route parameter, you should override the `getRouteKey` method on your Eloquent model:
51+
Если вы хотите настроить значение, которое помещается в параметр маршрута, вы должны переопределить метод `getRouteKey` в вашей модели Eloquent:
4852

4953
/**
50-
* Get the value of the model's route key.
54+
* Получить значение ключа маршрута модели.
5155
*
5256
* @return mixed
5357
*/
@@ -57,36 +61,36 @@ If you would like to customize the value that is placed in the route parameter,
5761
}
5862

5963
<a name="redirecting-controller-actions"></a>
60-
## Redirecting To Controller Actions
64+
## Перенаправление на методы контроллера
6165

62-
You may also generate redirects to [controller actions](/docs/{{version}}/controllers). To do so, pass the controller and action name to the `action` method:
66+
Вы также можете обеспечить перенаправления на [методы контроллера](/docs/{{version}}/controllers). Для этого передайте имя контроллера и его метода методу `action` экземпляра `redirect`:
6367

6468
use App\Http\Controllers\HomeController;
6569

6670
return redirect()->action([HomeController::class, 'index']);
6771

68-
If your controller route requires parameters, you may pass them as the second argument to the `action` method:
72+
Если метод контроллера требует параметров, вы можете передать их в качестве второго аргумента методу `action`:
6973

7074
return redirect()->action(
7175
[UserController::class, 'profile'], ['id' => 1]
7276
);
7377

7478
<a name="redirecting-with-flashed-session-data"></a>
75-
## Redirecting With Flashed Session Data
79+
## Перенаправление с данными сеанса
7680

77-
Redirecting to a new URL and [flashing data to the session](/docs/{{version}}/session#flash-data) are usually done at the same time. Typically, this is done after successfully performing an action when you flash a success message to the session. For convenience, you may create a `RedirectResponse` instance and flash data to the session in a single, fluent method chain:
81+
Перенаправление на новый URL-адрес и [передача данных в сеанс](/docs/{{version}}/session#flash-data) обычно выполняются одновременно. Обычно это делается после успешного выполнения действия, когда вы отправляете сообщение об успешном завершении сеанса. Для удобства вы можете создать экземпляр `RedirectResponse` и передать данные в сеанс в цепочке методов:
7882

7983
Route::post('/user/profile', function () {
8084
// Update the user's profile...
8185

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

85-
You may use the `withInput` method provided by the `RedirectResponse` instance to flash the current request's input data to the session before redirecting the user to a new location. Once the input has been flashed to the session, you may easily [retrieve it](/docs/{{version}}/requests#retrieving-old-input) during the next request:
89+
Вы можете использовать метод `withInput`, предоставляемый экземпляром `RedirectResponse`, для передачи входных данных текущего запроса в сеанс перед перенаправлением пользователя на новый URL. После того как данные были переданы в сеанс, вы можете легко [получить их](/docs/{{version}}/requests#retrieving-old-input) во время следующего запроса:
8690

8791
return back()->withInput();
8892

89-
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):
93+
После перенаправления вы можете отобразить всплывающее сообщение [сеанса](/docs/{{version}}/session). Например, используя [синтаксис Blade](/docs/{{version}}/blade):
9094

9195
@if (session('status'))
9296
<div class="alert alert-success">

0 commit comments

Comments
 (0)