Skip to content

Repeaters ​

A list of items people add, remove, reorder and edit together, kept as a JSON column:

php
Collaboration::room($invoice)->items('lines', text: ['description']);   // or 'lines' => 'items' in $collaborative

Sub-fields named in text merge by character, with carets; the others take the latest change. Each item is saved with a key, so it keeps its identity from one save to the next.

blade
@foreach ($lines as $index => $line)
    <input wire:model="lines.{{ $index }}.description" wire:key="{{ $line['key'] }}">
@endforeach
<button type="button" x-on:click="Collaboration.items($el, 'lines').add({ description: '' })">Add a line</button>

Released under the MIT License.