Skip to content

Commit d9ca974

Browse files
committed
Update docs
1 parent 7ddefd6 commit d9ca974

13 files changed

+24
-50
lines changed

docs/blade-helpers.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
extends: _layouts.v1-docs
3-
title: Blade Directives
4-
description: Blade Directives
3+
title: Blade Helpers
4+
description: Blade Directives and Components
55
order: 4
66
---
77

@@ -46,5 +46,3 @@ To the `:id` prop, you may pass a string, which will be used as-is as the DOM ID
4646
```
4747

4848
Additionally, you may also pass along any prop that is supported by the Turbo Frame custom Element to the `<x-turbo-frame>` Blade component, like `target`, `src`, or `loading`. These are the listed attributes, but any other attribute will also be forwarded to the `<turbo-frame>` tag that will be rendered by the `<x-turbo-frame>` component. For a full list of what's possible to do with Turbo Frames, see the [documentation](https://turbo.hotwired.dev/handbook/frames).
49-
50-
[Continue to Helper Functions...](/docs/{{version}}/helper-functions)

docs/broadcasting.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Broadcasting Turbo Streams
55
order: 7
66
---
77

8-
# Broadcasting Turbo Streams Over WebSockets With Laravel Echo
8+
# Broadcasting Turbo Streams
99

1010
So far, we have used Turbo Streams over HTTP to handle the case of updating multiple parts of the page for a single user after a form submission. In addition to that, you may want to broadcast model changes over WebSockets to all users that are viewing the same page. Although nice, **you don't have to use WebSockets if you don't have the need for it. You may still benefit from Turbo Streams over HTTP.**
1111

@@ -179,7 +179,7 @@ class Comment extends Model
179179

180180
This will also automatically hook into the model events, but instead of broadcasting new instances as `append` it will use `prepend`.
181181

182-
Secondly, it will send all changes to this model's broadacsting channel, except for when the model is created (since no one would be listening to its direct channel). In our case, we want to direct the broadcasts to the post linked to this model instead. We can achieve that by adding a `$broadcastsTo` property to the model, like so:
182+
Secondly, it will send all changes to this model's broadcasting channel, except for when the model is created (since no one would be listening to its direct channel). In our case, we want to direct the broadcasts to the post linked to this model instead. We can achieve that by adding a `$broadcastsTo` property to the model, like so:
183183

184184
```php
185185
class Comment extends Model
@@ -230,7 +230,7 @@ class Comment extends Model
230230
}
231231
```
232232

233-
Newly created models using the auto-broadcasting feature will be broadcasted to a pluralized version of the model's basename. So if you have a `App\Models\PostComment`, you may expect broadcasts of newly created models to be sent to a private channel called `post_comments`. Again, this convention is only valid for newly created models. Updates/Removals will still be sent to the model's own private channel by default using Laravel's convention for channel names. You may want to specify the channel name for newly created models to be broadcasted to with the `stream` key:
233+
Newly created models using the auto-broadcasting feature will be broadcasted to a pluralized version of the model's basename. So if you have a `App\Models\PostComment`, you may expect broadcasts of newly created models to be sent to a private channel called `post_comments`. Again, this convention is only valid for newly created models. Updates/Removals will still be sent to the model's own private channel by default using Laravel's convention for channel names. You may want to specify the channel name for newly created models to be broadcast to with the `stream` key:
234234

235235
```php
236236
class Comment extends Model
@@ -247,7 +247,7 @@ Having a `$broadcastsTo` property or implementing the `broadcastsTo()` method in
247247

248248
## Broadcasting Turbo Streams to Other Users Only
249249

250-
As mentioned erlier, you may want to feed the current user with Turbo Streams using HTTP requests and only send the broadcasts to other users. There are a couple ways you can achieve that.
250+
As mentioned earlier, you may want to feed the current user with Turbo Streams using HTTP requests and only send the broadcasts to other users. There are a couple ways you can achieve that.
251251

252252
First, you can chain on the broadcasting methods, like so:
253253

@@ -268,7 +268,7 @@ Turbo::broadcastToOthers(function () {
268268

269269
This way, any broadcast that happens inside the scope of the Closure will only be sent to other users.
270270

271-
Third, you may use that same method but without the Closure inside a ServiceProvider, for instance, to instruct the package to only send turbo stream broadcasts to other users globally:
271+
Third, you may use that same method but without the Closure inside a `ServiceProvider`, for instance, to instruct the package to only send turbo stream broadcasts to other users globally:
272272

273273
```php
274274
<?php
@@ -366,7 +366,7 @@ TurboStream::broadcastAction('scroll_to', target: 'todo_123');
366366

367367
## Handmade Broadcasting Using The `turbo_stream()` Response Builder
368368

369-
Alternatively to use the `TurboStream` Facade (or Factory type-hint), you may also broadcast directly from the `turbo_stream()` function response builder:
369+
Alternatively to using the `TurboStream` Facade (or Factory type-hint), you may also broadcast directly from the `turbo_stream()` function response builder:
370370

371371
```php
372372
turbo_stream()
@@ -389,7 +389,7 @@ turbo_stream($comment)
389389
->broadcastTo($comment->post, fn ($broadcast) => $broadcast->toOthers());
390390
```
391391

392-
Similarly to using the Facade, you may also want to broadcast to private or presence string channels like so:
392+
Similar to using the Facade, you may also want to broadcast to private or presence string channels like so:
393393

394394
```php
395395
// To private channels...
@@ -402,5 +402,3 @@ turbo_stream()
402402
->append('notifications', 'Hello World')
403403
->broadcastToPresenceChannel('chat.123', fn ($broadcast) => $broadcast->toOthers());
404404
```
405-
406-
[Continue to Livewire Integration...](/docs/{{version}}/livewire)

docs/conventions.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
extends: _layouts.v1-docs
3-
title: Convetions
3+
title: Conventions
44
description: All the (optional) conventions and recommendations
55
order: 3
66
---
@@ -15,7 +15,7 @@ Laravel supports [resource routes](https://laravel.com/docs/controllers#resource
1515

1616
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`.
1717

18-
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:
18+
You may define exceptions to the route guessing behavior by setting the `redirect_guessing_exceptions` in the `config/turbo-laravel.php` config file:
1919

2020
```php
2121
return [
@@ -26,16 +26,14 @@ return [
2626
];
2727
```
2828

29-
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.
29+
When using this config, the redirection behavior will still happen, but the package will not guess routes. See the [Validation Response Redirects](/1.x/docs/validation-response-redirects) page to know more about why this happens.
3030

3131
## Partials
3232

33-
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).
33+
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](/1.x/docs/turbo-streams).
3434

35-
The models' partials (such as the `comments/_comment.blade.php` for a `Comment` model) may only rely on having a single `$comment` instance variable passed to them. That's because the package will, by default, figure out the partial for a given model when broadcasting and will also pass the model to such partial, using the class basename as the variable instance in _camelCase_. Again, that's by default, you can customize most things. Read the [Broadcasting](/docs/{{version}}/broadcasting) section to know more.
35+
The models' partials (such as the `comments/_comment.blade.php` for a `Comment` model) may only rely on having a single `$comment` instance variable passed to them. That's because the package will, by default, figure out the partial for a given model when broadcasting and will also pass the model to such partial, using the class basename as the variable instance in _camelCase_. Again, that's by default, you can customize most things. Read the [Broadcasting](/1.x/docs/broadcasting) section to know more.
3636

3737
## Turbo Stream Channel Names
3838

39-
You may use the model's Fully Qualified Class Name (aka. FQCN) as your Broadcasting Channel authorization routes with a wildcard, such as `App.Models.Comment.{comment}` for a `Comment` model living in `App\\Models\\` - the wildcard's name doesn't matter, as long as there is one. This is the default [broadcasting channel naming convention](https://laravel.com/docs/8.x/broadcasting#model-broadcasting-conventions) in Laravel.
40-
41-
[Continue to Blade Helpers...](/docs/{{version}}/blade-helpers)
39+
You may use the model's Fully Qualified Class Name (aka. FQCN) as your Broadcasting Channel authorization routes with a wildcard, such as `App.Models.Comment.{comment}` for a `Comment` model living in `App\\Models\\` - the wildcard's name doesn't matter, as long as there is one. This is the default [broadcasting channel naming convention](https://laravel.com/docs/broadcasting#model-broadcasting-conventions) in Laravel.

docs/csrf.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,3 @@ Since Turbo.js intercepts form submissions and converts those to fetch requests
2424
```
2525

2626
With that being said, you may still want to use the `@csrf` Blade directive if you want to support users with JavaScript disabled, since the forms will still work if they contain the CSRF token.
27-
28-
[Continue to Turbo Native...](/docs/{{version}}/turbo-native)

docs/helper-functions.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dom_class($comment);
3535

3636
This function will generate the DOM class named based on your model's classname. If you have an instance of a `App\Models\Comment` model, it will generate a `comment` DOM class.
3737

38-
Similarly to the `dom_id()` function, you may also pass a context prefix as the second parameter:
38+
Similar to the `dom_id()` function, you may also pass a context prefix as the second parameter:
3939

4040
```php
4141
dom_class($comment, 'reactions_list');
@@ -67,8 +67,4 @@ return turbo_stream_view('comments.turbo.created', [
6767
]);
6868
```
6969

70-
---
71-
7270
All these functions are also registered globally, so you may use it directly without the `use` statements (this is useful in contexts like Blade views, for instance).
73-
74-
[Continue to Turbo Streams...](/docs/{{version}}/turbo-streams)

docs/installation.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,3 @@ php artisan turbo:install --alpine
4040
```
4141

4242
_Note: the `--jet` option also adds all the necessary Alpine dependencies since Jetstream depends on Alpine._
43-
44-
[Continue to Overview...](/docs/{{version}}/overview)

docs/known-issues.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ If you ever encounter an issue with the package, look here first for documented
1111

1212
## Fixing Laravel's Previous URL Issue
1313

14-
Visits from Turbo Frames will hit your application and Laravel by default keeps track of previously visited URLs to be used with helpers like `url()->previous()`, for instance. This might be confusing because chances are that you wouldn't want to redirect users to the URL of the most recent Turbo Frame that hit your app. So, to avoid storying Turbo Frames visits as Laravel's previous URL, head to the [issue](https://github.com/tonysm/turbo-laravel/issues/60#issuecomment-1123142591) where a solution was discussed.
14+
Visits from Turbo Frames will hit your application and Laravel by default keeps track of previously visited URLs to be used with helpers like `url()->previous()`, for instance. This might be confusing because chances are that you wouldn't want to redirect users to the URL of the most recent Turbo Frame that hit your app. So, to avoid storing Turbo Frames visits as Laravel's previous URL, head to the [issue](https://github.com/tonysm/turbo-laravel/issues/60#issuecomment-1123142591) where a solution was discussed.

docs/livewire.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,3 @@ Now, we can use this element in a page where we want to have the integration bet
105105
That's it! With that, we got Livewire to generate Turbo Streams, dispatch it as a browser event, which gets intercepted by our custom HTML element and applied to the page!
106106

107107
This is only an example of what a deeper integration could look like.
108-
109-
[Continue to Validation Response Redirects...](/docs/{{version}}/validation-response-redirects)

docs/overview.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,3 @@ As mentioned earlier, you may also trigger a Turbo Frame with forms and links th
5151
You could also "hide" this link and trigger a "click" event with JavaScript programmatically to trigger the Turbo Frame to reload, for example.
5252

5353
So far, all vanilla Hotwire and Turbo.
54-
55-
[Continue to Conventions...](/docs/{{version}}/conventions)

docs/testing.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,4 @@ class CreatesCommentsTest extends TestCase
149149
}
150150
```
151151

152-
*Note: If you're using the automatic model changes broadcasting, make sure your `turbo-laravel.queue` config key is set to false, otherwise actions may not be dispatched during test because the model observer only fires them after the transaction is commited, which never happens in tests since they run inside a transaction.*
153-
154-
[Continue to Known Issues...](/docs/{{version}}/known-issues)
152+
*Note: If you're using the automatic model changes broadcasting, make sure your `turbo-laravel.queue` config key is set to false, otherwise actions may not be dispatched during test because the model observer only fires them after the transaction is committed, which never happens in tests since they run inside a transaction.*

docs/turbo-native.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,3 @@ return [
9191
],
9292
];
9393
```
94-
95-
[Continue to Testing...](/docs/{{version}}/testing)

docs/turbo-streams.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
extends: _layouts.v1-docs
33
title: Turbo Streams
4-
description: The Turbo Streams Components and Helpers
4+
description: The Turbo Streams Components and Helpers
55
order: 6
66
---
77

@@ -57,7 +57,7 @@ Here's what the HTML response will look like:
5757
</turbo-stream>
5858
```
5959

60-
Most of these things were "guessed" based on the [naming conventions](/docs/{{version}}/conventions) we talked about earlier. But you can override most things, like so:
60+
Most of these things were "guessed" based on the [naming conventions](/1.x/docs/conventions) we talked about earlier. But you can override most things, like so:
6161

6262
```php
6363
return turbo_stream($comment)->target('post_comments');
@@ -94,7 +94,7 @@ turbo_stream()->remove($comment);
9494

9595
For these shorthand stream builders, you may pass an instance of an Eloquent model, which will be used to figure out things like `target`, `action`, and the `view` partial as well as the view data passed to them.
9696

97-
Alternativelly, you may also pass strings to the shorthand stream builders, which will be used as the target, and an optional content string, which will be rendered instead of a partial, for instance:
97+
Alternatively, you may also pass strings to the shorthand stream builders, which will be used as the target, and an optional content string, which will be rendered instead of a partial, for instance:
9898

9999
```php
100100
turbo_stream()->append('statuses', __('Comment was successfully created!'));
@@ -249,7 +249,7 @@ class ChirpsController extends Controller
249249
turbo_stream()->append('notifications', view('layouts.notification', [
250250
'message' => __('Chirp deleted.'),
251251
])),
252-
turbo_stream()->flash(__('Chirp deleted.')), // [tl! remove:-3,3 add]
252+
turbo_stream()->flash(__('Chirp deleted.')),
253253
]);
254254
}
255255

@@ -316,7 +316,7 @@ Remember, these are Blade views, so you have the full power of Blade at your han
316316
@endif
317317
```
318318

319-
Similar to the `<x-turbo-frame>` Blade component, there's also a `<x-turbo-stream>` Blade component that can simplify things a bit. It has the same convention of figureing out the DOM ID when you're passing a model instance or an array as the `<x-turbo-frame>` component applied to the `target` attribute. When using the component version, there's also no need to specify the template wrapper for the Turbo Stream tag, as that will be added by the component itself. So, the same example would look something like this:
319+
Similar to the `<x-turbo-frame>` Blade component, there's also a `<x-turbo-stream>` Blade component that can simplify things a bit. It has the same convention of figuring out the DOM ID when you're passing a model instance or an array as the `<x-turbo-frame>` component applied to the `target` attribute. When using the component version, there's also no need to specify the template wrapper for the Turbo Stream tag, as that will be added by the component itself. So, the same example would look something like this:
320320

321321
```blade
322322
@include('layouts.turbo.flash_stream')
@@ -347,5 +347,3 @@ Turbo.StreamActions.console_log = function () {
347347
```
348348

349349
Custom actions are only supported from Blade views. You cannot return those from controllers using the Pending Streams Builder, for instance.
350-
351-
[Continue to Broadcasting...](/docs/{{version}}/broadcasting)

docs/validation-response-redirects.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Examples:
2626

2727
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.
2828

29-
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.
29+
When you're not using the [resource route naming convention](/1.x/docs/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.
3030

3131
Here's how you may set the `redirectTo` property:
3232

@@ -82,5 +82,3 @@ class Kernel extends HttpKernel
8282
];
8383
}
8484
```
85-
86-
[Continue to CSRF Protection...](/docs/{{version}}/csrf)

0 commit comments

Comments
 (0)