# Upsert rows without a per-row form

> upsert writes a batch by a unique key. It skips model events, so a normal Vue form should still use create or update.

- URL: https://laravel-vuejs.space/laravel-upsert-vue
- Author: Anass Ez-zouaine (https://laravel-vuejs.space/author/anass-ez-zouaine)
- Published: 2026-10-11
- Topics: Laravel, VueJs

People searching “Laravel upsert” use it for the post form so they can skip the id. A form that creates or edits one post should use `create` or `update` from the [CRUD guide](https://laravel-vuejs.space/laravel-inertia-vue-crud). `upsert` is a batch import.

> **TL;DR**
>
> -   upsert writes a batch by a unique key.
> -   It skips model events, so a normal Vue form should still use create or update.
> -   Do not point an Inertia form at upsert for one title.
> -   Do not upsert from Vue by posting the whole table on every keystroke.
>
> **Who it's for:** Laravel + Vue developers
>
> **Applies to:** Laravel 13 · Vue 3

## The fix

```php
Post::upsert([
    ['slug' => 'hello', 'title' => 'Hello', 'user_id' => $request->user()->id],
], uniqueBy: ['slug'], update: ['title']);
```

`uniqueBy` is the unique index. `update` is the column list that changes when the slug already exists. Timestamps are not filled unless you pass them in the row. Observers and model events do not run.

Validate each row before this call. `upsert` is not a validator.

## What to avoid

> **Gotcha**
>
> Do not point an Inertia form at upsert for one title. You lose the policy events and the id comes back differently. Do not upsert from Vue by posting the whole table on every keystroke.

## FAQ

**Q: How do I upsert rows without a per-row form?**

upsert writes a batch by a unique key. It skips model events, so a normal Vue form should still use create or update.

**Q: What goes wrong with Laravel upsert?**

Many developers use it for the post form so they can skip the id. Do not point an Inertia form at upsert for one title.
