Action::make('addPayment')
->icon('heroicon-m-plus')
->iconButton()
->form([
Grid::make(2)
->schema([
TextInput::make('amount')
->label('Amount')
->prefix('$')
->numeric()
->required(),
DatePicker::make('created_at')
->label('Date')
->default(now())
->required(),
Select::make('payment_method')
->label('Payment Method')
->options(PaymentMethod::toArray())
->required(),
TextInput::make('payment_ref_number')
->label('Reference Number'),
Textarea::make('payment_memo')
->columnSpanFull()
->label('Memo')
->rows(2),
SpatieMediaLibraryFileUpload::make('attachments')
->appendFiles()
->openable()
->collection('resource_files')
->multiple()
->reorderable(),
])
])
->action(function (Order $record, array $data) {
$payment = $record
->payments()
->create([
'amount' => $data['amount'],
'payment_method' => $data['payment_method'],
'payment_ref_number' => $data['payment_ref_number'],
'payment_memo' => $data['payment_memo'],
'created_at' => $data['created_at'],
]);
Notification::make()
->title('Payment Added')
->success()
->send();
})