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?
}
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.