Skip to content

Commit 7fb7be6

Browse files
authored
Update README.md
1 parent a6b4464 commit 7fb7be6

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,23 @@ You can keep track of a lock version during a business transaction by informing
4949
```html
5050
<input type="hidden" name="lock_version" value="{{$blogPost->lock_version}}"
5151
```
52-
52+
and in controller:
53+
```php
54+
<?php
55+
56+
// Explicitly setting the lock version
57+
class PostController {
58+
public function update($id)
59+
{
60+
$post = Post::findOrFail($id);
61+
$post->lock_version = request('lock_version');
62+
$post->save();
63+
// You can also define more implicit reusable methods in your model like Model::saveWithVersion(...$args);
64+
// or just override the default Model::save(...$args); method which accepts $options
65+
// Then automatically read the lock version from Request and set into the model.
66+
}
67+
}
68+
```
5369

5470
So if two authors are editing the same content concurrently,
5571
you can keep track of your **Read State**, and ask the second

0 commit comments

Comments
 (0)