i am using dynamic component , this is my parent component
@foreach ($data['providers'] as $provider_index => $provider)
@php
$provider_count++;
@endphp
@livewire('app.admin.invoice.formsections.invoice-service-provider', ['provider' => $provider,'provider_index' => $provider_index,'rate_status' => $data['rate_status'],'provider_count' => $provider_count], key($provider_count))
@endforeach
and inside this component i want to populate dynamic values for every iteration ,
@if ($provider !== null && $provider['check_in_status'] !== null)
<tr>
<td style="vertical-align: top; line-height: normal;white-space: nowrap; width:36%;">
<p style="font-size: 19px;">{{ $provider['user']['name'] }}</p>
<div>
<?php
$this->provider['admin_approved_payment_detail']['actual_start_timestamp'] = modifyDateTimeFormat($provider['admin_approved_payment_detail']['actual_start_timestamp']);
$this->provider['admin_approved_payment_detail']['actual_end_timestamp'] = modifyDateTimeFormat($provider['admin_approved_payment_detail']['actual_end_timestamp']);
?>
<div class="d-flex">
<span style="font-size: 15px;">Start Time: </span>
<input type="text" wire:model="provider.admin_approved_payment_detail.actual_start_timestamp" class="header-inputs w-full ml-4 p-0" />
</div>
<div class="d-flex">
<span style="font-size: 15px;">End Time: </span>
<input type="text" wire:model="provider.admin_approved_payment_detail.actual_end_timestamp" class="header-inputs w-full ml-4 p-0" />
</div>
</div>
</td>
<td class=" text-wrap w-25" style="vertical-align: top; line-height: normal;white-space: nowrap; ">
@if ($rate_status > 0 && $rate_status !== 4)
<!-- Checking service type is greater than 0 & not fixed -->
@if (array_key_exists('total_durations_billing', $provider['billing_details']))
<div class="d-flex justify-center">
@if ($rate_status == 2)
<div>
<p>Days</p>
<input wire:model="provider.billing_details.total_durations_billing.days"
class="form-control form-control-sm w-50 text-center" />
</div>
<div>
<p>Hours</p>
<input type="number"
wire:model="provider.billing_details.total_durations_billing.hours"
class="form-control form-control-sm w-50 text-center" />
</div>
@elseif($rate_status == 1)
<div>
<p>Hours</p>
<input type="number"
wire:model="provider.billing_details.total_durations_billing.hours"
class="form-control form-control-sm w-50 text-center" />
</div>
<div>
<p>Minutes</p>
<input type="number" wire:model="provider.billing_details.total_durations_billing.mins"
class="form-control form-control-sm w-50 text-center" />
</div>
@endif
<input wire:model="provider.billing_details.total_provider_charges" type="number" style="background-color: #e9e9e9 !important;" class="form-control form-control-sm invoice-input"/>
</div>
@else
<div class="d-flex justify-center">
@if ($rate_status == 2)
<div>
<p>Days</p>
<input type="number" wire:model="provider.days"
class="form-control form-control-sm w-50 text-center" />
</div>
<div>
<p>Hours</p>
<input type="number" wire:model="provider.hours"
class="form-control form-control-sm w-50 text-center" />
</div>
@elseif($rate_status != 2)
<div>
<p>Hours</p>
<input type="number" wire:model="provider.hours"
class="form-control form-control-sm w-50 text-center" />
</div>
<div>
<p>Minutes</p>
<input type="number" wire:model="provider.mins"
class="form-control form-control-sm w-50 text-center" />
</div>
@endif
</div>
@endif
@endif
</td>
<td class="text-wrap" style="vertical-align: top; line-height: normal;white-space: nowrap; ">
<div class="d-flex flex-column gap-3 align-items-right">
<div class="d-flex justify-content-end gap-3">
<input disabled style="border:none;" value="Service Charges" type="text"
class="form-control form-control-sm inv_add_charges" />
<input wire:model.defer="provider.billing_details.service_charges"
wire:change="calculateTotalProviderCharges({{ $provider_index }})"
type="number" class="form-control form-control-sm invoice-input" />
</div>
@if (!empty($provider['billing_details']) && isset($provider['billing_details']['additional_charges']))
@foreach ($provider['billing_details']['additional_charges'] as $charge_index => $charge)
<div class="d-flex justify-content-end gap-3">
<input disabled style="border:none;"
wire:model="provider.billing_details.additional_charges.{{ $charge_index }}.label"
type="text" class="form-control form-control-sm inv_add_charges" />
<input
wire:model.defer="provider.billing_details.additional_charges.{{ $charge_index }}.charges"
wire:change="calculateTotalProviderCharges({{ $provider_index }})"
type="number" class="form-control form-control-sm invoice-input" />
</div>
@endforeach
@foreach ($provider['billing_details']['specialization_charges'] as $sp_index => $charge)
<div class="d-flex justify-content-end gap-3">
<input disabled style="border:none;"
wire:model="provider.billing_details.specialization_charges.{{ $sp_index }}.label"
type="text" class="form-control form-control-sm inv_add_charges" />
<input
wire:model.defer="provider.billing_details.specialization_charges.{{ $sp_index }}.charges"
wire:change="calculateTotalProviderCharges({{ $provider_index }})"
type="number" class="form-control form-control-sm invoice-input" />
</div>
@endforeach
@if (!empty($provider['service_payment_details']['expedited_rate']))
<div class="d-flex justify-content-end gap-3">
<input disabled style="border:none;" value="Expedition Charges" type="text"
class="form-control form-control-sm inv_add_charges" />
<input disabled wire:model.defer="provider.service_payment_details.expedited_rate"
wire:change="calculateTotalProviderCharges({{ $provider_index }})"
type="number" class="form-control form-control-sm invoice-input" />
</div>
@endif
@endif
<div class="d-flex justify-content-end gap-3 pt-2 pb-2 cursor-pointer" style="color: #0a1e46;">
<p data-toggle="modal"
wire:click="$emit('sendType',['line_item',{{ $provider_index }}, {{ $provider_index }} ])"
data-target="#addDiscount"><strong>Add line item discount
+</strong></p>
</div>
</div>
</td>
<td>
</td>
</tr>
<tr>
<td></td>
<td>
</td>
<td>
<div class="d-flex justify-content-end gap-3" wire:key="provider-{{ $provider_count }}-second">
{{$provider_count}}
<input disabled value="Total Provider Charges" style="border:none; font-weight:bolder" type="text"
class="form-control form-control-sm" />
{{-- <input wire:model="provider.billing_details.total_provider_charges" disabled type="text"
style="background-color: #e9e9e9 !important;" class="form-control form-control-sm invoice-input" /> --}}
{{-- <input wire:model="provider.{{$provider_index}}.billing_details.total_provider_charges" type="number" style="background-color: #e9e9e9 !important;" class="form-control form-control-sm invoice-input"/> --}}
<input wire:debug="provider.billing_details.total_provider_charges" disabled type="number" style="background-color: #e9e9e9 !important;" class="form-control form-control-sm invoice-input"/>
<p>{{$provider['billing_details']['total_provider_charges']}}</p>
{{-- <p>@dump($provider['billing_details'])</p> --}}
</div>
</td>
<td>
</td>
</tr>
@endif
this is my component logic
<?php
namespace AppHttpLivewireAppAdminInvoiceFormsections;
use LivewireComponent;
class InvoiceServiceProvider extends Component
{
public $showForm;
public $provider;
public $services_payload_data;
public $provider_index;
public $provider_count;
protected $listeners = ['showList' => 'resetForm'];
public function render()
{
return view('livewire.app.admin.invoice.formsections.invoice-service-provider');
}
public function mount($provider,$provider_index,$rate_status,$provider_count)
{
$this->provider = $provider;
$this->provider_index = $provider_index;
$this->rate_status = $rate_status;
$this->provider_count = $provider_count;
}
function showForm()
{
$this->showForm=true;
}
public function resetForm()
{
$this->showForm=false;
}
public function calculateTotalProviderCharges($provider_index){
$total_provider_charges = 0;
$service_charges_price = 0;
// dd($this->provider);
foreach($this->provider['billing_details'] as $index => $data){
//dd($data,$index,$this->provider['billing_details']);
if($index == 'additional_charges'){
foreach($data as $charges => $charge){
$total_provider_charges += (int)$charge['charges'];
}
}
if($index == 'specialization_charges'){
foreach($data as $charges => $charge){
$total_provider_charges += (int)$charge['charges'];
}
}
if($index == 'discounts_list'){
foreach($data as $discounts => $discount){
$total_provider_charges -= (int)$discount['value'];
}
}
if($index == 'service_charges'){
// foreach($data as $discounts => $discount){
// $total_provider_charges -= (int)$discount['value'];
// }
$service_charges_price = $data;
}
// if($index == 'expedited_charges'){
// foreach($data as $charges => $charge){
// //dd($charge);
// $total_provider_charges += $charge['charges'];
// }
// }
}
if($this->provider['service_payment_details']['expedited_rate']){
$total_provider_charges += $this->provider['service_payment_details']['expedited_rate'];
}else{
$total_provider_charges += 0;
}
$this->provider['billing_details']['total_provider_charges'] = number_format($total_provider_charges + $service_charges_price,2, '.', '');
// dd($this->provider['billing_details']['total_provider_charges']);
// $this->emit('providerChargesUpdated', $this->provider,$provider_index);
//$this->serviceTotal($this->provider);
}
}
the issue is that it is populating all the values properly except the provider.billing_details.total_provider_charges , i have tried dumping the value , it exists , i tried printing the value in the first row , it does print value and also reflects the change whenever i change the
<input disabled style="border:none;" value="Service Charges" type="text"
class="form-control form-control-sm inv_add_charges" />
<input wire:model.defer="provider.billing_details.service_charges"
wire:change="calculateTotalProviderCharges({{ $provider_index }})"
type="number" class="form-control form-control-sm invoice-input" />
the only issue is that it does not print the value in second row , i have already passed the unique key for each row wire:key=”provider-{{ $provider_count }}-second” but still does not work , any help will be appreciated as i have already wasted a lot of time trying to solve this