Restore a soft-deleted row from Vue

The restore route uses withTrashed() or the binding 404s before your controller runs.

For your AI agent

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

Read https://laravel-vuejs.space/laravel-restore-soft-delete-vue.md
The restore route uses withTrashed() or the binding 404s before your controller runs.
Do not turn withTrashed() on for the whole route group.
Do not restore in the browser by clearing deletedat on the prop.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Laravel restore soft delete” call restore() on a normal route and get a 404. The row is deleted, so binding cannot see it. Opt in on that route only.

TL;DR

  • The restore route uses withTrashed() or the binding 404s before your controller runs.
  • Do not turn withTrashed() on for the whole route group.
  • Do not restore in the browser by clearing deleted_at on the prop.

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

Applies to: Laravel 13 · Inertia 3 · Vue 3

The fix#

php
Route::post('/posts/{post}/restore', [PostController::class, 'restore'])
    ->withTrashed()
    ->middleware('auth')
    ->name('posts.restore');
php
public function restore(Post $post): RedirectResponse
{
    $this->authorize('restore', $post);
    $post->restore();

    return back();
}

The Vue button posts to that URL. It sits on the trash list, which used onlyTrashed(). A normal edit form should not offer restore.

What to avoid#

Gotcha

Do not turn withTrashed() on for the whole route group. Edit and update would start opening deleted posts. Do not restore in the browser by clearing deleted_at on the prop. The column is not yours to edit from the page.

FAQ#

How do I restore a soft-deleted row from Vue?

The restore route uses withTrashed() or the binding 404s before your controller runs.

What goes wrong with Laravel restore soft delete?

Many developers call restore() on a normal route and get a 404. Do not turn withTrashed() on for the whole route group.

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.