You can bind to models within an Eloquent Collection. Scroll down a little from the link below for details.
https://laravel-livewire.com/docs/2.x/properties#binding-models
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have been stuck in this for some time now.
I have the following query where I get incomes from a MySQL view.
How do store these results and use wire:model as below
$first = DB::table('view_information_invoices')
->select('department', 'inhouse_id', 'date', 'reference', DB::raw('"MMK" as currency_code'), 'amount_mmk as amount')
->where('amount_mmk', '>', 0)
->where('inhouse_id', 1);
$payments = DB::table('view_information_invoices')
->select('department', 'inhouse_id', 'date', 'reference', DB::raw('"USD" as currency_code'), 'amount_usd as amount')
->where('amount_usd', '>', 0)
->where('inhouse_id', 1)
->union($first)
->get();
And for each of the above, I have to create many ChaeckOutPayments with the currency type, and amout from the user, and for that, I created the following table:
<thead class="bg-gray-50">
<tr class="divide-x">
<x-th-slim>Department</x-th-slim>
<x-th-slim>Currency</x-th-slim>
<x-th-slim>Amount</x-th-slim>
<x-th-slim>Paid Currency</x-th-slim>
<x-th-slim>Rate</x-th-slim>
<x-th-slim>Paid Amount</x-th-slim>
<x-th-slim>City Ledger</x-th-slim>
<x-th-slim>Payment</x-th-slim>
<x-th-slim>Remark</x-th-slim>
</tr>
</thead>
<tbody class="bg-white">
@foreach ($checkOutPayments as $key => $payment)
<tr class="divide-x">
<x-td-slim>{{ $payment['department'] }}</x-td-slim>
<x-td-slim>{{ $payment['currency_code'] }}</x-td-slim>
<x-td-slim>{{ $payment['amount'] }}</x-td-slim>
<x-td-slim>
<select wire:model="???"
class="mt-1 block w-full rounded-md border-gray-300 py-1 pl-3 pr-10 text-base focus:border-
indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm">
@foreach ($currencyExchanges as $currency)
<option value="{{ $currency->from_currency_code }}">
{{ $currency->from_currency_code }}
</option>
@endforeach
</select>
</x-td-slim>
<x-td-slim>Dynamic Rate</x-td-slim>
<x-td-slim>
<input wire:model="???" />
</x-td-slim>
<x-td-slim>0</x-td-slim>
<x-td-slim>Payment T Selector</x-td-slim>
<x-td-slim>Remark</x-td-slim>
</tr>
@endforeach
</tbody>
</table>
Please shed some light on how should approach this. I have tried storing the query results into an array and tried to loop over them to bind with wire:model but it's not working.
Please or to participate in this conversation.