Merge Methods
To merge a prop instead of overwriting it, you may use theInertia::merge() method when returning your response.
Inertia::merge() method will append new items to existing arrays at the root level. You may change this behavior to prepend items instead.
Matching Items
When merging arrays, you may use thematchOn parameter to match existing items by a specific field and update them instead of appending new ones.
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::deepMerge()to ensure a deep merge of the entire structure.
Inertia::deepMerge() was introduced before Inertia::merge() had support for prepending and targeting nested paths. In most cases, Inertia::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 can also combine deferred props with mergeable props to defer the loading of the prop and ultimately mark it as mergeable once it’s loaded.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 props keys you would like to reset.