Reject a Vue form that edited a stale row

Send updated_at with the form and compare it before you write. Do not use HTTP 409 for that.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/laravel-updated-at-check-vue.md
Send updated_at with the form and compare it before you write. Do not use HTTP 409 for that.
Do not use HTTP 409 for that.
Do not compare a date string you formatted for humans.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Laravel optimistic lock Vue” want two editors to stop overwriting each other. Send the updated_at you rendered, and refuse the write when it no longer matches. This is not an Inertia visit feature. It is a check in the controller. The CRUD guide is the form.

TL;DR

  • Send updated_at with the form and compare it before you write.
  • Do not use HTTP 409 for that.
  • Do not abort(409) here.
  • Do not compare a date string you formatted for humans.

Who it's for: Laravel + Vue developers on Inertia

Applies to: Laravel 13 · Inertia 3 · Vue 3

The fix#

php
$validated = $request->validate([
    'title' => ['required', 'string', 'max:120'],
    'updated_at' => ['required', 'date'],
]);

if (! $post->updated_at->equalTo($request->date('updated_at'))) {
    return back()->withErrors([
        'title' => 'This post changed. Reload and try again.',
    ]);
}

$post->update(['title' => $validated['title']]);

The Vue form sends the prop, not the clock on the laptop:

vue
<input type="hidden" name="updated_at" :value="post.updated_at" />

What to avoid#

Gotcha

Do not abort(409) here. Inertia uses 409 when the asset version changed after a deploy, and the client reloads instead of showing the error bag. Do not compare a date string you formatted for humans. Compare the timestamp the model cast.

FAQ#

How do I reject a Vue form that edited a stale row?

Send updated_at with the form and compare it before you write. Do not use HTTP 409 for that.

What goes wrong with Laravel optimistic lock Vue?

Many developers want two editors to stop overwriting each other. Do not abort(409) here.

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.