Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

andyandy's avatar

Livewire multiple inputs with the same model name

Let's say Im generating a list of Companies with option to upload their logo:

@foreach($companies as $company)
	<h2>{{ $company->id}} {{ $company->name}}</h2>
	<input type="file" wire:model="uploadLogo">
@endforeach

How do I tell which company logo is being uploaded (since the model name is same for all companies)?


public function updatedUploadLogo(){
	// input for which company am I processing?
}

0 likes
1 reply
andyandy's avatar
andyandy
OP
Best Answer
Level 4

I made an extra vaiable uploadCompanyLogo_company_id and when the upload input is clicked the variable is set to company_id which solves the issue.

<label class="upload" wire:click="$set('uploadCompanyLogo_company_id', {{ $company->id }})">
    <input type="file" wire:model="uploadCompanyLogo">
</label>

Please or to participate in this conversation.