Modal Action not work
->extraModalFooterActions([
Action::make('250dinar')
->label('250 Dinar')
->extraAttributes(['class' => 'w-1/2 !h-full'])
->action(function (Get $get, Set $set) {
$this->updatePaidAndPayback($get, $set, 250);
}),
Action::make('500dinar')
->label('500 Dinar')
->action(function (Get $get, Set $set) {
$this->updatePaidAndPayback($get, $set, 500);
}),
Action::make('1hazar')
->label('1 Hazar')
->action(function (Get $get, Set $set) {
$this->updatePaidAndPayback($get, $set, 1000);
}),
Action::make('5hazar')
->label('5 Hazar')
->action(function (Get $get, Set $set) {
$this->updatePaidAndPayback($get, $set, 5000);
}),
Action::make('10hazar')
->label('10 Hazar')
->action(function (Get $get, Set $set) {
$this->updatePaidAndPayback($get, $set, 10000);
}),
])
->extraModalFooterActions([
Action::make('250dinar')
->label('250 Dinar')
->extraAttributes(['class' => 'w-1/2 !h-full'])
->action(function (Get $get, Set $set) {
$this->updatePaidAndPayback($get, $set, 250);
}),
Action::make('500dinar')
->label('500 Dinar')
->action(function (Get $get, Set $set) {
$this->updatePaidAndPayback($get, $set, 500);
}),
Action::make('1hazar')
->label('1 Hazar')
->action(function (Get $get, Set $set) {
$this->updatePaidAndPayback($get, $set, 1000);
}),
Action::make('5hazar')
->label('5 Hazar')
->action(function (Get $get, Set $set) {
$this->updatePaidAndPayback($get, $set, 5000);
}),
Action::make('10hazar')
->label('10 Hazar')
->action(function (Get $get, Set $set) {
$this->updatePaidAndPayback($get, $set, 10000);
}),
])
2 Replies
We need more info. Like what does the
updatePaidAndPayback()
function do?This is the function
But i think the main reason is the actions not work
up
public function updatePaidAndPayback(Get $get, Set $set, int $value): void
{
$totalPrice = (int) $get('total_price');
$paidPrice = (int) $get('paid_price') + $value;
if ($paidPrice > $totalPrice) {
Notification::make()
->title('Error')
->body('Paid price cannot be greater than total price.')
->danger()
->send();
return;
}
$paybackPrice = max(0, $totalPrice - $paidPrice);
$set('paid_price', $paidPrice);
$set('payback_price', number_format($paybackPrice));
}
public function updatePaidAndPayback(Get $get, Set $set, int $value): void
{
$totalPrice = (int) $get('total_price');
$paidPrice = (int) $get('paid_price') + $value;
if ($paidPrice > $totalPrice) {
Notification::make()
->title('Error')
->body('Paid price cannot be greater than total price.')
->danger()
->send();
return;
}
$paybackPrice = max(0, $totalPrice - $paidPrice);
$set('paid_price', $paidPrice);
$set('payback_price', number_format($paybackPrice));
}