Table Header Actions: How to access data?
I have a RelationManager table, and I am trying to add a quick payment action on it which would create a new PaymentRecord
Trying to figure out how to access PhoneMembership info
->headerActions([
Tables\Actions\Action::make('quick-payment')->label('Quick Payment')
->action(function (PhoneMembership $record, array $data) {
dd($data);
})
->color('success'),
Tables\Actions\CreateAction::make()->label('Add Manual Transaction')->slideOver()->modalWidth('lg'),
])->headerActions([
Tables\Actions\Action::make('quick-payment')->label('Quick Payment')
->action(function (PhoneMembership $record, array $data) {
dd($data);
})
->color('success'),
Tables\Actions\CreateAction::make()->label('Add Manual Transaction')->slideOver()->modalWidth('lg'),
])Trying to figure out how to access PhoneMembership info
$record->phoneMembershipRecords()->create([
'date' => now(),
'type' => EType::CREDIT,
'value' => $data['value'],
'memo' => 'Quick payment',
]);$record->phoneMembershipRecords()->create([
'date' => now(),
'type' => EType::CREDIT,
'value' => $data['value'],
'memo' => 'Quick payment',
]);
Solution
Tables\Actions\Action::make('quick-payment')->label('Quick Payment')
->action(function () {
$this->ownerRecord->phoneMembershipRecords()->create([
'date' => now(),
'type' => EType::CREDIT,
'value' => $this->ownerRecord->billing_cycle * $this->ownerRecord->monthly_rate,
'memo' => 'Quick Payment',
]);
}) Tables\Actions\Action::make('quick-payment')->label('Quick Payment')
->action(function () {
$this->ownerRecord->phoneMembershipRecords()->create([
'date' => now(),
'type' => EType::CREDIT,
'value' => $this->ownerRecord->billing_cycle * $this->ownerRecord->monthly_rate,
'memo' => 'Quick Payment',
]);
})