loadCartFromDb(); } #[On('cart-updated')] public function onCartUpdated(): void { $this->syncTotalPriceFromCart(); } protected function syncTotalPriceFromCart(): void { $total = (int) FeedPurchaseItem::where('feed_purchase_id', $this->record->id)->sum('subtotal'); $this->form->fill([ ...$this->form->getState(), 'total_price' => $total, ]); } protected function getHeaderActions(): array { return [ BackAction::make() ->url(ListFeedPurchases::getUrl()), ]; } protected function getRedirectUrl(): string { return $this->getResource()::getUrl('index'); } protected function mutateFormDataBeforeSave(array $data): array { $total = FeedPurchaseItem::where('feed_purchase_id', $this->record->id)->sum('subtotal'); $data['total_price'] = $total; return $data; } protected function getSavedNotification(): ?Notification { return Notification::make() ->title('Perubahan Berhasil Disimpan') ->body('Perubahan pada data telah berhasil disimpan dan diperbarui di sistem.') ->success(); } }