Merge Methods
To merge a prop instead of overwriting it, you may useinertia::merge()inertia.Merge()Inertia::merge() when returning your response.
append_at() or prepend_at()AppendAt() or PrependAt()append() or prepend().
Matching Items
When merging arrays, you may match existing items by a specific field and update them instead of appending duplicates by chaining.match_on(...) with the nested path to the keychaining .MatchOn(...) with the nested path to the keypassing matchOn to append().
data array and attempt to match each item by its id field. If a match is found, the existing item will be replaced. If no match is found, the new item will be appended.
Deep Merge
Instead of specifying which nested paths should be merged, you may useinertia::deep_merge()inertia.DeepMerge()Inertia::deepMerge() to ensure a deep merge of the entire structure.
merge() supported prepending and targeting nested paths. In most cases, merge() with its append and prepend methods should be sufficient.
Client-Side Visits
You can also merge props directly on the client side without making a server request using client side visits. Inertia provides prop helper methods that allow you to append, prepend, or replace prop values.Combining with Deferred Props
You may combine deferred props with mergeable props to defer the loading of the prop and ultimately mark it as mergeable once it’s loaded.Combining with Once Props
You may chain theonce()Once()once() modifier onto a merge prop to ensure the data is resolved only once and remembered by the client across subsequent navigations.
Resetting Props
On the client side, you can indicate to the server that you would like to reset the prop. This is useful when you want to clear the prop value before merging new data, such as when the user enters a new search query on a paginated list. Thereset request option accepts an array of the prop keys you would like to reset.