D Terminal Dev
D Terminal Dev
FFilament
Created by D Terminal Dev on 6/21/2024 in #❓┊help
Show item preview when repeater item is collapsed
like have a method called collapsedFormat(), u get a cllback with the row item and return a string to show in the collapsed view
3 replies
FFilament
Created by D Terminal Dev on 6/21/2024 in #❓┊help
Refresh repeater values when value outside repeater changes
thank you sir, fixed it by doing this:
Forms\Components\TextInput::make('tva')->default(19)->live()->label('TVA')->suffix('%')->afterStateUpdated(function ($state, $get, $set) {
// dd($get('products'));
// if($state == 0) return;
foreach ($get('products') as $key => $data) {
$vat_val = (double)$state / 100;
if (!$data['product'] && !$data['qty']) continue;


$with_vat = $state == 0 ? 0 : $data['total_price_no_vat'] * (1 + $vat_val);

$vat = $state == 0 ? 0 : $data['total_price_no_vat'] * $vat_val;
$set("products.$key.total_price_vat", round($with_vat, 2));
$set("products.$key.total_vat", round($vat, 2));
}
})->numeric(),
Forms\Components\TextInput::make('tva')->default(19)->live()->label('TVA')->suffix('%')->afterStateUpdated(function ($state, $get, $set) {
// dd($get('products'));
// if($state == 0) return;
foreach ($get('products') as $key => $data) {
$vat_val = (double)$state / 100;
if (!$data['product'] && !$data['qty']) continue;


$with_vat = $state == 0 ? 0 : $data['total_price_no_vat'] * (1 + $vat_val);

$vat = $state == 0 ? 0 : $data['total_price_no_vat'] * $vat_val;
$set("products.$key.total_price_vat", round($with_vat, 2));
$set("products.$key.total_vat", round($vat, 2));
}
})->numeric(),
in my afterStateUpdated on the prop that changes
4 replies