To reset the replyMessage field to a blank value after the action is completed, you can use the reset method on the form that is available within the action closure. The reset method will reset the form fields to their initial state. Since you want to reset the replyMessage field after the action is completed, you should call the reset method after the message has been created and before the halt method is called if you want to halt the action.
Here's how you can modify your action method to reset the replyMessage field:
->action(function ($action, ChatSession $record, array $data, $arguments, Set $set, Get $get) {
$chatMessageService = new ChatMessageService();
$chatMessageService->create($record->id, $data['replyMessage'], auth()->user()->id);
// Reset the replyMessage field to its initial state (which is an empty string)
$action->form->fill([
'replyMessage' => '',
]);
// If you want to halt the action, do it after resetting the form
if ($arguments['halt'] === true) {
$action->halt();
}
})
In this code snippet, the fill method is used to set the replyMessage field to an empty string, effectively resetting it. This is done before the halt method is called, ensuring that the reset operation is executed regardless of whether the action is halted or not.
Make sure that the fill method is called on the correct form instance ($action->form in this case) and that the field name (replyMessage) matches the name used in the form definition.
This should reset the replyMessage field to a blank value after the action is completed, and before the modal is closed if the halt argument is true.