Laravel Livewire 2.6: Indirect modification of overloaded element of Illuminate\Database\Eloquent\Collection has no effect

Viewed 180

Based on https://laravel-news.com/livewire-v2-6-0, Livewire has supported deep model data binding. And I write the following codes to test the feature:

$details = new Collection([
    new Detail(['quantity' => 10, 'amount' => 5]),
]);

$this->receive = new Receive;
$this->receive->setRelation('details', $details);
<div>
    @foreach($receive->details as $index => $detail)
    <input type="text" wire:model="receive.details.{{ $index }}.quantity" wire:key="receive.details.{{ $index }}.quantity">
    @endforeach
</div>

When I changed the quantity, I got the following error:

Indirect modification of overloaded element of Illuminate\Database\Eloquent\Collection has no effect

But, if I query the receive from database, it works fine.

$this->receive = Receive::find(1);

Any idea what could be happening here? Any help or guidance is much appreciated.

0 Answers
Related