Skip to content

Commit e5995e2

Browse files
committed
docs tweaks
1 parent b49b694 commit e5995e2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

docs/conventions.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ Laravel supports [resource routes](https://laravel.com/docs/controllers#resource
1212

1313
If you don't want to use resource routes, at least consider using the naming convention: render forms in a route name ending in `.create` or `.edit` and name their handler routes ending with `.store` or `.update`.
1414

15+
You may want to define exceptions to the route guessing behavior. In that case, you may want to set the `redirect_guessing_exceptions` in the `config/turbo-laravel.php` config file:
16+
17+
```php
18+
return [
19+
// ...
20+
'redirect_guessing_exceptions' => [
21+
'/some-page',
22+
],
23+
];
24+
```
25+
26+
When using this config, the redirection behavior will still happen, but the package will not guess routes. See the [Validation Response Redirects](/docs/{{version}}/validation-response-redirects) page to know more about why this happens.
27+
1528
## Partials
1629

1730
You may want to split up your views in smaller chunks (aka. "partials"), such as `comments/_comment.blade.php` which displays a comment resource, or `comments/_form.blade.php` for the form to either create/update comments. This will allow you to reuse these _partials_ in [Turbo Streams](/docs/{{version}}/turbo-streams).

docs/validation-response-redirects.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ Examples:
2121
- `comments.store` will guess the form is at the `comments.create` route with no route params.
2222
- `comments.update` will guess the form is at the `comments.edit` with the `{comment}` param.
2323

24-
If a guessed route name doesn't exist (which will always happen if you don't use the route resorce convention), the middleware will not change the default handling of validation errors. You may also override this behavior by catching the `ValidationException` yourself and re-throwing it overriding the redirect with the `redirectTo` method. If the exception has that, the middleware will respect it and make a GET request to that location instead of trying to guess it.
24+
If a guessed route name doesn't exist (which will always happen if you don't use the route resource convention), the middleware will not change the default handling of validation errors.
25+
26+
When you're not using the [resource route naming convention](/docs/{{version}}/conventions), you can override redirect behavior by catching the `ValidationException` yourself and re-throwing it overriding the redirect with the `redirectTo` method. If the exception has that, the middleware will respect it and make a GET request to that location instead of trying to guess it.
2527

2628
Here's how you may set the `redirectTo` property:
2729

@@ -36,6 +38,19 @@ public function store()
3638
}
3739
```
3840

41+
You may want to have exceptions to the route guessing behavior, which you can use the `redirect_guessing_exceptions` config in the `config/turbo-laravel.php` config file:
42+
43+
```php
44+
return [
45+
// ...
46+
'redirect_guessing_exceptions' => [
47+
'/some-page',
48+
],
49+
];
50+
```
51+
52+
The internal redirect will still happen, but the resource route convention will not be used.
53+
3954
## Turbo HTTP Middleware
4055

4156
The package ships with a middleware which applies some conventions on your redirects, specially around how failed validations are handled automatically by Laravel. Read more about this in the [Conventions](#conventions) section of the documentation.

0 commit comments

Comments
 (0)